#!/bin/sh

PATH=/usr/sbin:/sbin:/bin

test -f /usr/sbin/paneld || exit 0
# Exit if we're not running on a Cobalt system.
if [ -e /proc/cpuinfo ] && ! $(grep -qe "system type.*: Cobalt" /proc/cpuinfo); then
    exit 0
fi


BANNER="'Debian GNU/Linux'"
if [ -f /etc/default/colo ]; then
    . /etc/default/colo
fi

case "$1" in
    start)
        echo -n "Starting Cobalt LCD admin menu: paneld"
        eval start-stop-daemon --start --quiet --pidfile /var/run/paneld.pid --exec /usr/sbin/paneld -b -m -- $BANNER
        echo "."
        ;;

    stop)
        echo -n "Stopping Cobalt LCD admin menu: paneld"
        start-stop-daemon --stop --quiet --pidfile /var/run/paneld.pid
        # clear the LCD
        putlcd
        echo "."
        ;;
    restart|force-reload)
        echo -n "Restarting Cobalt LCD admin menu: paneld"
        start-stop-daemon --stop --quiet --pidfile /var/run/paneld.pid
        eval start-stop-daemon --start --quiet --pidfile /var/run/paneld.pid --exec /usr/sbin/paneld -b -m -- $BANNER
        echo "."
        ;;
    *)
        echo "Usage: /etc/init.d/colo {start|stop|restart|force-reload}"
        exit 1
        ;;
esac

exit 0

