You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.2 KiB
77 lines
1.2 KiB
6 years ago
|
#!/bin/sh
|
||
|
|
||
|
. /etc/init.d/globals
|
||
4 years ago
|
. /etc/init.d/functions
|
||
6 years ago
|
|
||
6 years ago
|
# Neutrino's exit codes
|
||
|
ERROR=-1
|
||
|
NORMAL=0
|
||
|
SHUTDOWN=1
|
||
|
REBOOT=2
|
||
|
|
||
6 years ago
|
# if neutrino crashes, just restart it or reboot the box?
|
||
4 years ago
|
case "$(get_boxmodel)" in
|
||
|
nevis|apollo|shiner|kronos|kronos_v2)
|
||
|
REBOOT_ON_ERROR=true
|
||
|
;;
|
||
|
*)
|
||
|
REBOOT_ON_ERROR=false
|
||
|
;;
|
||
|
esac
|
||
6 years ago
|
|
||
|
do_cleanup() {
|
||
|
# remove files created by neutrino
|
||
|
rm -f /tmp/.timer
|
||
|
}
|
||
|
|
||
|
do_shutdown() {
|
||
4 years ago
|
display_msg "N: SHUTDOWN"
|
||
6 years ago
|
poweroff
|
||
|
}
|
||
|
|
||
|
do_reboot() {
|
||
4 years ago
|
display_msg "N: REBOOT"
|
||
6 years ago
|
reboot
|
||
|
}
|
||
|
|
||
|
while true; do
|
||
|
do_cleanup
|
||
|
|
||
4 years ago
|
if [ -e /var/etc/.coredump ]; then
|
||
|
# unlimit core file size
|
||
|
ulimit -c unlimited
|
||
|
fi
|
||
|
|
||
6 years ago
|
neutrino; RET=$?
|
||
|
LOGINFO "Neutrino exited with exit code $RET"
|
||
|
|
||
6 years ago
|
if [ $RET -eq $NORMAL ]; then
|
||
6 years ago
|
# do nothing
|
||
|
break
|
||
6 years ago
|
elif [ $RET -eq $SHUTDOWN ]; then
|
||
6 years ago
|
do_shutdown
|
||
|
break
|
||
6 years ago
|
elif [ $RET -eq $REBOOT ]; then
|
||
6 years ago
|
do_cleanup
|
||
|
do_reboot
|
||
|
break
|
||
|
fi
|
||
|
|
||
4 years ago
|
display_msg "NEUTRINO: $RET"
|
||
6 years ago
|
|
||
|
# report errors on external display
|
||
4 years ago
|
if [ -e /tmp/.lcd-* -a -e /tmp/lcd ]; then
|
||
6 years ago
|
echo "0" > /tmp/lcd/mode_logo
|
||
|
echo "Neutrino" > /tmp/lcd/service
|
||
|
echo "Error: $RET" > /tmp/lcd/event
|
||
|
fi
|
||
|
|
||
|
if $REBOOT_ON_ERROR; then
|
||
|
LOGINFO "Rebooting due to REBOOT_ON_ERROR=true and exit code $RET"
|
||
|
do_reboot
|
||
|
break
|
||
|
fi
|
||
|
|
||
4 years ago
|
LOGINFO "Restarting Neutrino after exit code $RET"
|
||
6 years ago
|
done
|