forked from wifislax-ng/wifislax-updaters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredis_updater
executable file
·167 lines (146 loc) · 3.93 KB
/
redis_updater
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/sh
# Script by www.seguridadwireless.net
SCRIPT_VERSION=20151116
############################################################
## Funciones comunes. Su nombre empieza por f_ ##
############################################################
f_variables(){
. /opt/wifislax-updaters/Funciones/funciones_updater
}
############################################################
## Funciones propias del script. Su nombre empieza por F_ ##
############################################################
# Definicion de variables
F_variables() {
PRGNAM=redis
echo -ne "\033]2;${PRGNAM}_updater\007"
WEB="http://download.redis.io/"
VERSION=$(curl -sk ${WEB}releases/ | grep "tar\.gz" | grep -Po 'href="\K.*(?=</.>)' | cut -d\" -f1 | grep -E '[0-9]\.' | tail -1|rev | cut -d. -f3- | rev |sed "s/$PRGNAM//g" | cut -d- -f2)
EXTENSION=tar.gz
SOURCES=$PRGNAM-$VERSION.$EXTENSION
DOWNLOAD="${WEB}releases/$SOURCES"
}
# Descomprimimos el fichero descargado y compilamos
F_compilar(){
# Use our CFLAGS.
sed -i "s|-O3||" deps/Makefile deps/hiredis/Makefile
# No ./configure necessary.
# http://lists.slackbuilds.org/pipermail/slackbuilds-users/2013-January/010042.html
( unset ARCH ; CFLAGS="$SLKCFLAGS" make )
make install PREFIX=$PKG/usr
# Use sample config and set some sane defaults.
install -D -m 0644 redis.conf $PKG/etc/redis/redis.conf
sed -i \
-e 's|^daemonize no|daemonize yes|' \
-e 's|^dir \.|dir /var/lib/redis|' \
-e 's|^logfile ""|logfile /var/log/redis/redis.log|' \
-e 's|^# bind 127.0.0.1|bind 127.0.0.1|' \
-e 's|^# unixsocket /tmp/redis.sock|unixsocket /tmp/redis.sock|' \
-e 's|^# unixsocketperm 700|unixsocketperm 700|' \
$PKG/etc/redis/redis.conf
install -D -m 0644 sentinel.conf $PKG/etc/redis/sentinel.conf
# Create data directory.
mkdir -p $PKG/var/lib/redis
chmod 0700 $PKG/var/lib/redis
# Create log directory.
mkdir -p $PKG/var/log/redis
# Install init script.
mkdir -p $PKG/etc/rc.d
echo "#!/bin/sh
#
# Redis startup script for Slackware Linux
PORT=6379
SERV=/usr/bin/redis-server
CLI=/usr/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF=/etc/redis/redis.conf
redis_start() {
if [ ! -r \$CONF ]; then
echo \"\$CONF does not appear to exist. Abort.\"
exit 1
fi
if [ -s \$PIDFILE ]; then
echo \"Redis appears to be already running?\"
exit 1
fi
echo \"Starting Redis server...\"
\$SERV \$CONF
}
redis_stop() {
if [ ! -s \$PIDFILE ]; then
echo \"\$PIDFILE does not exist or is empty.\"
exit 1
fi
PID=\$(cat \$PIDFILE)
echo -n \"Stopping Redis server...\"
\$CLI -p \$PORT shutdown
while [ -d /proc/\$PID ]; do
sleep 1
echo -n \".\"
done
echo \" done\"
}
redis_restart() {
redis_stop
sleep 3
redis_start
}
case \"\$1\" in
start)
redis_start
;;
stop)
redis_stop
;;
restart)
redis_restart
;;
*)
echo \"Usage: \$0 {start|stop|restart}\"
exit 1
esac
"> $PKG/etc/rc.d/rc.redis
# Install logrotate script.
mkdir -p $PKG/etc/logrotate.d
echo "/var/log/redis/redis.log {
daily
rotate 7
copytruncate
delaycompress
compress
notifempty
missingok
}
" > $PKG/etc/logrotate.d/redis
}
###################################
## BLOQUE PRINCIPAL DE EJECUCION ##
###################################
# Si se cierra el script inesperadamente, ejecutar la funcion de limpieza
trap f_exitmode SIGHUP SIGINT
#Inicializamos las variables globales
f_variables
#Comprobamos conexion a Internet
f_comprobarConexion
#Inicializamos las variables del script
F_variables
#Creamos directorio de trabajo
f_directorioTemporal
#Mostramos el mensaje de presentacion
f_presentacion
#Comprobamos updates del script
f_comprobarUpdates
#Asignamos o detectamos arquitectura
f_arquitectura
#Comprobamos version instalada del paquete
f_versionInstalada
#Si no existe el fichero se descargara
f_download
#Preparamos entorno
f_preparar
#Descomprimir fichero descargado y compilamos
F_compilar
#Hacemos strip sobre el paquete
f_strip
#Creamos xzm , instalamos y salimos
f_tareasFinales