#!/bin/sh

[ -x /hdd/root/startup.sh ] && {
  # Put the programs you want to run in /hdd/root/startup.sh
  # These will be started when enigma is running for 30 seconds.
  # Within these 30 seconds the network should be running.
  ( sleep 30; /hdd/root/startup.sh ) &
}

[ -x /var/bin/camd.romu ] && /var/bin/camd.romu >/dev/null 2>&2 &
/bin/update_tmp.sh

while :
do
  /bin/enigma
  case "$?" in
    0)
      echo "Halt"
      /bin/update_var.sh
      sync;/sbin/halt
      ;;
    1)
      echo "reboot"
      /bin/update_var.sh
      sync;/sbin/reboot
      ;;
    2)
      echo "Restart"
      ;;
    *)
      echo "Crash"
      /bin/update_var.sh
      sync;/sbin/halt
      ;;
  esac
done
