-
Notifications
You must be signed in to change notification settings - Fork 0
/
Updaters_Test
executable file
·134 lines (118 loc) · 3.18 KB
/
Updaters_Test
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
#!/bin/bash
SCRIPTVERSION=1.3
# v1.2 Se añade funcion timeout
# v1.1 Se añade mensaje si todos los upadters funcionan
clear
# Algunos updaters necesitan arquitectura para saber version
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
export ARCH
export LIBDIRSUFFIX
# Colores
CIERRE=${CIERRE:-"[0m"}
ROJO=${ROJO:-"[1;31m"}
VERDE=${VERDE:-"[1;32m"}
CYAN=${CYAN:-"[1;36m"}
AMARILLO=${AMARILLO:-"[1;33m"}
BLANCO=${BLANCO:-"[1;37m"}
ROSA=${ROSA:-"[1;35m"}
echo "#############################"
echo "### $CYAN TESTER DE UPDATERS $CIERRE ###"
echo "#############################"
if [ ! "$(ping google.com -c1 2>/dev/null)" ]; then
echo ""
echo "No tengo internet ... el script se cerrara."
echo ""
sleep 1
exit 0
fi
BUSQUEDA(){
TMP=/tmp/Updaters_Test
if [ -d $TMP ]; then
rm -rf $TMP
fi
mkdir -p $TMP
cd /opt/wifiway-updaters
UPDATERS=$(find . -type f -name "*_updater")
echo
echo "${BLANCO}[${VERDE}*${BLANCO}]$AMARILLO Copiando updaters a directorio temporal ..."
cp -rf $UPDATERS $TMP &>/dev/null
rm -rf $TMP/linux* &>/dev/null
rm -rf $TMP/funciones_updater &>/dev/null
rm -rf $TMP/wifiway-updaters_updater &>/dev/null
rm -rf $TMP/last_update &>/dev/null
rm -rf $TMP/firefox_multi_updater &>/dev/null
}
TEMPORAL(){
cd $TMP
TEMPUPDATERS=$(find . -type f -name "*_updater"|sort)
echo "${BLANCO}[${VERDE}*${BLANCO}]$AMARILLO Modificando copias temporales de updaters ..."
for UPDATER in $TEMPUPDATERS; do
LINEA=$(grep -r "f_exitmode" -n $UPDATER|tr -d [a-zA-Z#_.:/])
FINAL=$(cat $UPDATER|wc -l)
ELIMINAR=$(expr $FINAL + 1)
sed -i "${LINEA},${ELIMINAR}d" $UPDATER
#echo f_variables >> $UPDATER
echo F_variables >> $UPDATER
echo 'if [ -z $VERSION ]; then' >> $UPDATER
echo 'VERSION="[1;31mFallido [0m"' >> $UPDATER
echo 'echo "$PRGNAM" >> "./FALLIDOS"' >> $UPDATER
echo 'fi' >> $UPDATER
echo 'printf "%-52s [1;37mVersion:[1;32m${VERSION}[0m\n" "[1;37mPrograma:[1;36m${PRGNAM}"' >> $UPDATER
done
}
MOSTRAR(){
echo "${BLANCO}[${VERDE}*${BLANCO}]$AMARILLO Testeando updaters..."
echo
sleep 3
for UPDATER in $TEMPUPDATERS ; do
timeout -s SIGTERM 5 sh -c "$TMP/$UPDATER"||printf "%-52s [1;37mVersion:[1;31mTIMEOUT[0m\n" "[1;37mPrograma:[1;36m$(echo $UPDATER|cut -d / -f2|sed 's/_updater//g')"
done
}
INFORME(){
clear
echo
echo "#############################"
echo "### $ROJO INFORME DE ERRORES $CIERRE ###"
echo "#############################"
echo
if [ -f $TMP/FALLIDOS ]; then
echo "${BLANCO}[${VERDE}*${BLANCO}] Los siguientes updaters fallaron"
echo $BLANCO
cat $TMP/FALLIDOS
echo $CIERRE
else
echo "${BLANCO}[${VERDE}*${BLANCO}] ${VERDE}!!! Enhorabuena !!!"
echo "${BLANCO}[${VERDE}*${BLANCO}] Todos los upadters funcionan."
fi
}
LIMPIAR(){
echo "${BLANCO}[${VERDE}*${BLANCO}] Limpiando directorio temporal ..."
sleep 1
rm -rf $TMP
echo "${BLANCO}[${VERDE}*${BLANCO}] Bye Bye"
echo $CIERRE
}
BUSQUEDA
TEMPORAL
MOSTRAR
INFORME
LIMPIAR