Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 83a1865

Browse files
committed
Merge pull request #73 from lobocobra/patch-1
Fix error in start script
2 parents 3f41d6b + 8eb0b39 commit 83a1865

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

bin/hyperion.init.sh

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ DAEMON=hyperiond
77
DAEMONOPTS="/etc/hyperion.config.json"
88
DAEMON_PATH="/usr/bin"
99

10-
NAME=$DEAMON
10+
NAME=$DAEMON
1111
DESC="Hyperion ambilight server"
1212
PIDFILE=/var/run/$NAME.pid
1313
SCRIPTNAME=/etc/init.d/$NAME
14-
1514
case "$1" in
1615
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
2320
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
2631
fi
2732
;;
2833
status)
@@ -39,24 +44,31 @@ status)
3944
fi
4045
;;
4146
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
4959
else
50-
printf "%s\n" "pidfile not found"
60+
printf "%-50s\n" "No PID file $NAME not running?"
5161
fi
5262
;;
5363

5464
restart)
55-
$0 stop
56-
$0 start
65+
$0 stop
66+
$0 start
5767
;;
5868

5969
*)
6070
echo "Usage: $0 {status|start|stop|restart}"
6171
exit 1
6272
esac
73+
74+
exit 0

0 commit comments

Comments
 (0)