
#mount -o remount,rw,sync /mnt/flash
mount -o remount,rw /mnt/flash

rm /www/update.tgz

echo "save manuals"             >  /www/update.log
mv /mnt/flash/manual /


echo "remove old files"         >> /www/update.log
rm /mnt/flash/eproms/*
killall snmpd
sleep 2
rm -r /mnt/flash/packages/snmp/usr

. flash_files/remove_old_files

echo "stop mini_httpd"          >> /www/update.log
killall mini_httpd

echo "copy packages and config" >> /www/update.log
cp  -a  flash_files/packages  /mnt/flash/   
cp  -a  flash_files/eproms    /mnt/flash/   
cp  -a  flash_files/config    /mnt/flash/   

echo "restore manuals"          >> /www/update.log
mv /manual /mnt/flash

echo "------------------------" >> /www/update.log
df                              >> /www/update.log
echo "OK:    Update completed." >> /www/update.log
echo "***********************************************" >> /www/update.log
echo "System will be rebooted automatically after 30s" >> /www/update.log
echo "***********************************************" >> /www/update.log

sync &

./reboot_after_30s &

echo "-------   Update completed  -------"


