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 manager vtund vtundsrv"
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 /tmp/manager.log
}
remove_opkg_lists() {
rm -Rf /tmp/opkg-lists/
}
return_to_operating_mode() {
# Start up the services we stopped
err=0
for name in $serviceslist
do
"/etc/init.d/${name}" start
if [ "$?" != "0" ]; then
err=-1
fi
done
rm -f /tmp/.upgrade_mode
exit $err
}
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