Hola, lo de que descarge actualizaciones pero que no se instalen y queden a la espera
de revision es interesante, como lo haces?
Saludos
En el /bin/thinclient cambie la linea
. /tmp/thinclient.sh
Por:
TCDIR="/etc/thinclient-scripts/"
LASTFILE="$(ls $TCDIR | sort -n | tail -n1)"
COPY=0
if [ -z "$LASTFILE" ]; then
COPY=1
else
LASTCS="$(md5sum $TCDIR/$LASTFILE | cut -d\ -f1)"
NEWCS="$(md5sum /tmp/.thinclient.sh | cut -d\ -f1)"
echo "$LASTCS $NEWCS"
if [ "$LASTCS" != "$NEWCS" ]; then
COPY=1
else
echo "Esta actualizacion ya existe."
fi
fi
if [ "$COPY" -eq 1 ]; then
NEWFILE="$TCDIR/thinclient-$(date '+%Y%m%d-%H%M')"
echo "Copiando el archivo de actualizacion a $NEWFILE"
cp /tmp/.thinclient.sh $NEWFILE
else
echo "No hay novedades"
fi
. /jffs/Actualizaciones/revisiones.sh
Y creo el directorio
thinclient-scripts en etc.
Creo en /jffs la carpeta
Actualizaciones y meto el siguiente script
revisiones.sh:
Revisado#!/bin/sh
echo "Preparando la actualización..."
cd /etc/thinclient-scripts
Ultima=$(ls thin*|sort -n|tail -n1)
cd /jffs/Actualizaciones
echo "echo 'Bajando los upgrades...'" > update.sh
for i in $(grep wget /etc/thinclient-scripts/$Ultima|cut -d " " -f 2); do
a=$(echo $i|sed -e 's/\// /g'|cut -d " " -f 6,7,8)
firm=$(echo $a|cut -d " " -f 1)
version=$(echo $a|cut -d " " -f 2)
Filename=$(echo $a|cut -d " " -f 3)
if [ ! -e upgrade-$firm-v$version.tar.gz -a ! -e reflash-$firm-v$version.tar.gz ]; then
echo "wget $i" >> update.sh
echo "mv $Filename upgrade-$firm-v$version.fon" >> update.sh
fi
done
sh update.sh
rm update.sh
echo "Extrayendo los upgrades comprimidos..."
if [ -e "upgrade-*.fon" ]; then
for i in upgrade-*.fon; do
dd if=$i of=version.tmp bs=1 count=4 > /dev/null 2>&1
VERSION=$(cat version)
if [ "$VERSION" = "FON3" ]; then
a=$(echo $i|sed -e 's/upgrade/reflash/'|sed -e 's/\.fon//')
else
a=$(echo $i|sed -e 's/\.fon//')
fi
cat $i|tail -c +520 - > $a.tar.gz
rm $i
done
rm version.tmp
fi
echo "Proceso Finalizado"
De esta manera una vez finalizado el proceso quedan en /jffs/Actualizaciones todos
los tar.gz de actualizacion que manda fon, las actualizaciones que requieran
reflashear se nombran
reflash-firm-version.tar.gz donde firm es la version del firm, version es la revision.
Lo pongo por separado por si alguien no quiere crear de modo automatico los tar.gz,
solo tiene que comentar con # la ultima linea en /bin/thinclient y después usar el script
de /jffs/Actualizaciones/revisiones.sh cuando quiera crearlos.
Después me los descargo en el pc haciendo:
cd /jffs/Actualizaciones
httpd -p 9090
y desde el pc abro en el navegador
http://la_ip_de_la_fonera:9090/nombre_del_Archivo_que_quiero_revisarHe creado en /jffs/ la carpeta
Backup-Sistem y copio en la carpeta los archivos:
/etc/firewall.user/bin/thinclientCreo en dicha carpeta el archivo:
thinclient.script#**********************************************************
TCDIR="/etc/thinclient-scripts"
LASTFILE="$(ls $TCDIR/thinclient-* | sort -n | tail -n1)"
COPY=0
if [ -z "$LASTFILE" ]; then
COPY=1
else
LASTCS="$(md5sum $LASTFILE | cut -d\ -f1)"
NEWCS="$(md5sum /tmp/.thinclient.sh | cut -d\ -f1)"
echo "$LASTCS $NEWCS"
if [ "$LASTCS" != "$NEWCS" ]; then
COPY=1
else
echo "Already seen this file."
fi
fi
if [ "$COPY" -eq 1 ]; then
NEWFILE="$TCDIR/thinclient-$(date '+%Y%m%d-%H%M')"
echo "Copying new instruction set to $NEWFILE"
cp /tmp/.thinclient.sh $NEWFILE
else
echo "Nothing new here."
fi
creo el script:
preservarSSH.sh en /etc/init.d
#!/bin/sh
ln -sf /etc/init.d/dropbear /etc/init.d/S50dropbear
a=$(md5sum /jffs/Backup-Sistem/firewall.user|cut -d " " -f 1)
b=$(md5sum /etc/firewall.user|cut -d " " -f 1)
if [ $b != $a ]; then
cp -a /etc/firewall.user /jffs/Backup-Sistem/firewall.user.fon
cp -a /jffs/Backup-Sistem/firewall.user /etc
fi
a=$(md5sum /jffs/Backup-Sistem/thinclient|cut -d " " -f 1)
b=$(md5sum /bin/thinclient|cut -d " " -f 1)
if [ $b != $a ]; then
grep -v "\. /tmp/\.thin" /bin/thin* > /tmp/thinclient.tmp
cat /jffs/Backup-Sistem/thinclient.script >> /tmp/thinclient.tmp
cat /tmp/thinclient.tmp > /bin/thinclient
cp -a /bin/thinclient /jffs/Backup-Sistem/thinclient.fon
cp -a /jffs/Backup-Sistem/thinclient /bin/thinclient
rm /tmp/thinclient.tmp
fi
y hago el enlace simbolico para el boot:
ln -sf /etc/init.d/preservarSSH.sh /etc/init.d/S10preservarSSH.sh
De este modo puedo aplicar las actualizaciones de fon, que no supongan un reflash de la fonera sin perder el acceso por SSH.
