2017-01-12 12:47:03 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Alphabetical except where noted below
|
|
|
|
# log needs to start before cron (and maybe others) to be detected for logging.
|
2017-04-11 20:26:28 -06:00
|
|
|
serviceslist="log cron dropbear linkled snmpd vtund vtundsrv xinetd"
|
2017-01-12 12:47:03 -07:00
|
|
|
|
|
|
|
start_upgrade_mode() {
|
|
|
|
|
|
|
|
touch /tmp/.upgrade_mode
|
|
|
|
|
|
|
|
# drop the page cache to take pressure of tmps when uploading file
|
|
|
|
echo 3 > /proc/sys/vm/drop_caches
|
|
|
|
|
|
|
|
#Kill processes
|
|
|
|
|
|
|
|
for name in $serviceslist
|
|
|
|
do
|
|
|
|
"/etc/init.d/${name}" stop
|
|
|
|
done
|
|
|
|
|
|
|
|
# Switch to a limited crontab list
|
|
|
|
/usr/sbin/crond -b -c /etc/crontabs.upgrademode -l 5
|
|
|
|
|
|
|
|
# Some services need to kill the last remaining processes
|
|
|
|
killall -9 dropbear
|
|
|
|
|
|
|
|
# Put the LED in "upgrade" mode
|
|
|
|
/usr/local/bin/linkled upgrade
|
|
|
|
|
|
|
|
# Purge the /tmp/ filesystem of unneeded files.
|
2017-03-20 23:42:58 -06:00
|
|
|
rm -Rf /tmp/node.history /tmp/snrlog/ /tmp/snr.dat /tmp/web/firmware.list /tmp/.uci
|
2017-01-12 12:47:03 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_opkg_lists() {
|
|
|
|
rm -Rf /tmp/opkg-lists/
|
|
|
|
}
|
|
|
|
|
|
|
|
return_to_operating_mode() {
|
|
|
|
|
|
|
|
killall -9 crond
|
|
|
|
|
|
|
|
# If anything goes wrong after this point return the error code to the calling process
|
|
|
|
# as we could be in an unstable state.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Start up the services we stopped
|
|
|
|
for name in $serviceslist
|
|
|
|
do
|
|
|
|
"/etc/init.d/${name}" start
|
|
|
|
done
|
|
|
|
|
|
|
|
rm /tmp/.upgrade_mode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"upgrade" )
|
|
|
|
start_upgrade_mode
|
|
|
|
remove_opkg_lists
|
|
|
|
;;
|
|
|
|
"opkginstall" )
|
|
|
|
start_upgrade_mode
|
|
|
|
;;
|
|
|
|
"restore" )
|
|
|
|
return_to_operating_mode
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "This program is not intended to be called by users."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|