2017-01-12 12:47:03 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Alphabetical except where noted below
|
2022-03-09 13:21:37 -07:00
|
|
|
# log needs to start first to be detected for logging.
|
2022-03-14 20:23:03 -06:00
|
|
|
serviceslist="log dropbear manager vtund vtundsrv"
|
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
|
|
|
|
|
|
|
|
# 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.
|
2022-03-13 21:19:04 -06:00
|
|
|
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
|
2017-01-12 12:47:03 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_opkg_lists() {
|
|
|
|
rm -Rf /tmp/opkg-lists/
|
|
|
|
}
|
|
|
|
|
|
|
|
return_to_operating_mode() {
|
|
|
|
|
|
|
|
# Start up the services we stopped
|
2023-01-29 20:21:03 -07:00
|
|
|
err=0
|
2017-01-12 12:47:03 -07:00
|
|
|
for name in $serviceslist
|
|
|
|
do
|
|
|
|
"/etc/init.d/${name}" start
|
2023-01-29 20:21:03 -07:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
err=-1
|
|
|
|
fi
|
2017-01-12 12:47:03 -07:00
|
|
|
done
|
|
|
|
|
2022-03-13 21:19:04 -06:00
|
|
|
rm -f /tmp/.upgrade_mode
|
2017-01-12 12:47:03 -07:00
|
|
|
|
2023-01-29 20:21:03 -07:00
|
|
|
exit $err
|
2017-01-12 12:47:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"upgrade" )
|
|
|
|
start_upgrade_mode
|
2022-03-13 21:19:04 -06:00
|
|
|
remove_opkg_lists
|
2017-01-12 12:47:03 -07:00
|
|
|
;;
|
|
|
|
"opkginstall" )
|
|
|
|
start_upgrade_mode
|
|
|
|
;;
|
|
|
|
"restore" )
|
|
|
|
return_to_operating_mode
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "This program is not intended to be called by users."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|