aredn/files/usr/local/bin/uploadctlservices

74 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# Alphabetical except where noted below
# log needs to start before cron (and maybe others) to be detected for logging.
serviceslist="log cron dropbear linkled snmpd vtund vtundsrv xinetd"
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.
rm -Rf /tmp/node.history /tmp/snrlog/ /tmp/snr.dat /tmp/web/firmware.list /tmp/.uci
}
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