aredn/files/usr/local/bin/uploadctlservices

70 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Alphabetical except where noted below
# log needs to start first to be detected for logging.
serviceslist="log dropbear 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
# 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/olsrd.log /tmp/olsrd.watchdog /tmp/snrlog/ /tmp/snr.dat /tmp/web/firmware.list /tmp/.uci
}
remove_opkg_lists() {
rm -Rf /tmp/opkg-lists/
}
return_to_operating_mode() {
# 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