-
Notifications
You must be signed in to change notification settings - Fork 0
/
alarmclock
executable file
·47 lines (40 loc) · 919 Bytes
/
alarmclock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
DIR="/home/pi/alarmclock"
cd $DIR
action="$1"
if pgrep "web.py" > /dev/null
then
STATUS="active"
else
STATUS="stopped"
fi
# if action not supplied at the command prompt
# display usae message and die
[ $# -eq 0 ] && { echo "Usage: $0 start|stop|status"; exit 0; }
# start web.py and exit script
if [ $1 = "start" ];then
if [ $STATUS = "active" ];then
echo "alarmclock allready active"
exit 0
else
echo "starting alarmclock"
${DIR}/web.py &> /dev/null &
exit 0
fi
#stop web.py and exit script
elif [ $1 = "stop" ];then
if [ $STATUS = "stopped" ];then
echo "alarmclock is not active"
exit 0
else
echo "stopping alarmclock"
pkill web.py
pkill mplayer
exit 0
fi
#status web.py and exit script
elif [ $1 = "status" ] ; then
echo "alarmclock $STATUS"
exit 0
fi
exit 1