#!/bin/sh . /etc/init.d/globals # if neutrino crashes, just restart it or reboot the box? REBOOT_ON_ERROR=true do_cleanup() { # remove files created by neutrino rm -f /tmp/.reboot /tmp/.timer } do_shutdown() { dt -t"SHUTDOWN" TIMER="/tmp/.timer" if [ -e $TIMER ]; then # send timers, led and bright settings to frontpanel if type shutdown_helper > /dev/null; then PARAM=`cat $TIMER` echo "calling 'shutdown_helper "$PARAM"'" shutdown_helper $PARAM fi fi poweroff } do_reboot() { dt -t"REBOOT" reboot } while true; do do_cleanup neutrino; RET=$? LOGINFO "Neutrino exited with exit code $RET" if [ $RET -eq 0 ]; then # do nothing break elif [ $RET -eq 1 ]; then do_shutdown break elif [ $RET -eq 2 ]; then do_reboot break fi dt -t"NEUTRINO: $RET" # report errors on external display if [ -e /tmp/.lcd-usbdev?.? ]; then 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 LOGINFO "Restarting neutrino after exit code $RET" done