#!/bin/sh
# checks for a sheduled time to shutdown geexbox

while true; do
  shutdowntime=`cat /var/downtime`
  if [ "$shutdowntime" != "0" ]; then
    uptime=`cat /proc/uptime | cut -f1 -d.`
    if [ "$uptime" -gt "$shutdowntime" ]; then
      echo "### Sleeptimer is powering system down ###"
      echo "quit 166" > /var/mp_control
      echo "166" > /tmp/mp_result
      exit 0
    fi
  fi
  sleep 60
done
