Skip to content

Commit 998450b

Browse files
authored
Initd fixes (#10)
* stop service when uninstalling package * Use initd daemon func instead of nohup If a user were to try to install bashrpc over ssh where there is not a tty shell, then nohup is completely ineffective.
1 parent a50beca commit 998450b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

dist/init/sysvinit/bashrpc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
DESC="bashrpc"
1313
NAME=bashrpc
1414
DAEMON=/usr/local/bin/bashrpc
15-
16-
15+
PIDFILE=/var/run/$NAME.pid
1716
LOGFILE=/var/log/$NAME.log
1817
CONFIGFILE=/etc/bashrpc/bashrpc.yml
1918

2019
test -x $DAEMON || exit 0
2120

21+
# source init.d functions
22+
. /etc/init.d/functions
23+
2224
start() {
2325
touch $LOGFILE
24-
nohup "$DAEMON" -c "$CONFIGFILE" --log "$LOGFILE" &
26+
daemon --pidfile "$PIDFILE" "$DAEMON" -c "$CONFIGFILE" --log "$LOGFILE"
2527
}
2628

2729
stop() {
28-
pkill -f "$DAEMON"
30+
killproc -p "$PIDFILE"
2931
}
3032

3133
reload() {

dist/scripts/postremove.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
service_manager=$(ps --no-headers -o comm 1)
44

5+
# stop the bashrpc service if it's running
6+
service bashrpc stop &>/dev/null
7+
58
if [ "$service_manager" = init ]; then
69
echo "+ removing init script"
710
rm -f /etc/init.d/bashrpc

0 commit comments

Comments
 (0)