This repository was archived by the owner on May 6, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +32
-20
lines changed Expand file tree Collapse file tree 1 file changed +32
-20
lines changed Original file line number Diff line number Diff line change @@ -7,22 +7,27 @@ DAEMON=hyperiond
7
7
DAEMONOPTS=" /etc/hyperion.config.json"
8
8
DAEMON_PATH=" /usr/bin"
9
9
10
- NAME=$DEAMON
10
+ NAME=$DAEMON
11
11
DESC=" Hyperion ambilight server"
12
12
PIDFILE=/var/run/$NAME .pid
13
13
SCRIPTNAME=/etc/init.d/$NAME
14
-
15
14
case " $1 " in
16
15
start)
17
- printf " %-50s" " Starting $NAME ..."
18
- cd $DAEMON_PATH
19
- PID=` $DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $! `
20
- # echo "Saving PID" $PID " to " $PIDFILE
21
- if [ -z $PID ]; then
22
- printf " %s\n" " Fail"
16
+ if [ $( pgrep -l $NAME | wc -l) = 1 ]
17
+ then
18
+ printf " %-50s\n" " Already running..."
19
+ exit 1
23
20
else
24
- echo $PID > $PIDFILE
25
- printf " %s\n" " Ok"
21
+ printf " %-50s" " Starting $NAME ..."
22
+ cd $DAEMON_PATH
23
+ PID=` $DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $! `
24
+ # echo "Saving PID" $PID " to " $PIDFILE
25
+ if [ -z $PID ]; then
26
+ printf " %s\n" " Fail"
27
+ else
28
+ echo $PID > $PIDFILE
29
+ printf " %s\n" " Ok"
30
+ fi
26
31
fi
27
32
;;
28
33
status)
@@ -39,24 +44,31 @@ status)
39
44
fi
40
45
;;
41
46
stop)
42
- printf " %-50s" " Stopping $NAME "
43
- PID=` cat $PIDFILE `
44
- cd $DAEMON_PATH
45
- if [ -f $PIDFILE ]; then
46
- kill -HUP $PID
47
- printf " %s\n" " Ok"
48
- rm -f $PIDFILE
47
+ if [ -f $PIDFILE ]
48
+ then
49
+ printf " %-50s" " Stopping $NAME "
50
+ PID=` cat $PIDFILE `
51
+ cd $DAEMON_PATH
52
+ if [ -f $PIDFILE ]; then
53
+ kill -HUP $PID
54
+ printf " %s\n" " Ok"
55
+ rm -f $PIDFILE
56
+ else
57
+ printf " %s\n" " pidfile not found"
58
+ fi
49
59
else
50
- printf " %s \n" " pidfile not found "
60
+ printf " %-50s \n" " No PID file $NAME not running? "
51
61
fi
52
62
;;
53
63
54
64
restart)
55
- $0 stop
56
- $0 start
65
+ $0 stop
66
+ $0 start
57
67
;;
58
68
59
69
* )
60
70
echo " Usage: $0 {status|start|stop|restart}"
61
71
exit 1
62
72
esac
73
+
74
+ exit 0
You can’t perform that action at this time.
0 commit comments