85 lines
2.0 KiB
Plaintext
85 lines
2.0 KiB
Plaintext
|
#!/bin/bash
|
||
|
### BEGIN INIT INFO
|
||
|
# Provides: pie-time
|
||
|
# Required-Start: $network
|
||
|
# Required-Stop: $network
|
||
|
# Should-Start: $local_fs
|
||
|
# Should-Stop: $local_fs
|
||
|
# Default-Start: 2 3 4 5
|
||
|
# Default-Stop: 0 1 6
|
||
|
# Short-Description: Desk clock application for the Raspberry Pi
|
||
|
# Description: Desk clock application for the Raspberry Pi
|
||
|
### END INIT INFO
|
||
|
|
||
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||
|
DAEMON="/usr/bin/pie_time"
|
||
|
NAME="pie-time"
|
||
|
DESC="Desk clock application for the Raspberry Pi"
|
||
|
|
||
|
RUNDIR="/var/run/pie-time"
|
||
|
PIDFILE="/var/run/pie-time/pie-time.pid"
|
||
|
WORKDIR="/var/lib/pie-time"
|
||
|
|
||
|
CONFIG_PATH="/etc/pie-time.ini"
|
||
|
USER="root"
|
||
|
|
||
|
if [ -f "/etc/default/pie-time" ];then
|
||
|
. "/etc/default/pie-time"
|
||
|
fi
|
||
|
|
||
|
. /lib/lsb/init-functions
|
||
|
|
||
|
set -e
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
echo -n "Starting $DESC: "
|
||
|
mkdir -p $RUNDIR
|
||
|
chmod 755 $RUNDIR
|
||
|
|
||
|
chown $USER $RUNDIR
|
||
|
|
||
|
if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --chdir $WORKDIR -b -m --exec $DAEMON -- $CONFIG_PATH;then
|
||
|
echo "$NAME."
|
||
|
else
|
||
|
echo "failed"
|
||
|
fi
|
||
|
;;
|
||
|
stop)
|
||
|
echo -n "Stopping $DESC: "
|
||
|
if start-stop-daemon --stop --retry forever/TERM/1 --quiet --oknodo --pidfile $PIDFILE;then
|
||
|
echo "$NAME."
|
||
|
rm -f $PIDFILE
|
||
|
else
|
||
|
echo "failed"
|
||
|
fi
|
||
|
;;
|
||
|
restart|force-reload)
|
||
|
${0} stop
|
||
|
${0} start
|
||
|
;;
|
||
|
status)
|
||
|
STATUS="4"
|
||
|
start-stop-daemon --status --pidfile $PIDFILE || STATUS="$?"
|
||
|
case $STATUS in
|
||
|
0)
|
||
|
echo "$NAME: running"
|
||
|
;;
|
||
|
|
||
|
1|3)
|
||
|
echo "$NAME: not running"
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo "$NAME: unable to determine the status"
|
||
|
;;
|
||
|
esac
|
||
|
;;
|
||
|
*)
|
||
|
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit 0
|