Skip to content

Commit bdbb64a

Browse files
committed
chore(conf): update sysv init script
Stop service by exact pid the service started.
1 parent 3589ba8 commit bdbb64a

File tree

1 file changed

+50
-39
lines changed
  • conf/systemV/etc/init.d

1 file changed

+50
-39
lines changed

conf/systemV/etc/init.d/ghfs

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,59 +19,70 @@
1919
ghfs="/usr/local/bin/ghfs"
2020
prog=$(basename $ghfs)
2121

22+
sysconfig="/etc/sysconfig/$prog"
23+
[ -f "$sysconfig" ] && . "$sysconfig"
24+
25+
pidfile="/var/run/${prog}.pid"
26+
2227
start() {
23-
echo -n $"Starting $prog: "
24-
"$ghfs" --config=/etc/ghfs.conf &
25-
retval=$?
26-
[ $retval -eq 0 ] && success || failure
27-
echo
28-
return $retval
28+
echo -n $"Starting $prog: "
29+
"$ghfs" --config=/etc/ghfs.conf &
30+
retval=$?
31+
echo
32+
if [ $retval -eq 0 ]; then
33+
echo -n "$!" >"$pidfile"
34+
success
35+
else
36+
failure
37+
fi
38+
return $retval
2939
}
3040

3141
stop() {
32-
echo -n $"Stopping $prog: "
33-
killproc "$prog"
34-
retval=$?
35-
echo
36-
return $retval
42+
echo -n $"Stopping $prog: "
43+
killproc -p "$pidfile" "$prog"
44+
retval=$?
45+
echo
46+
return $retval
3747
}
3848

3949
restart() {
40-
stop
41-
start
50+
stop
51+
start
4252
}
4353

4454
_status() {
45-
status $prog
55+
status $prog
4656
}
4757

4858
_status_q() {
49-
_status > /dev/null 2>&1
59+
_status >/dev/null 2>&1
5060
}
5161

5262
case "$1" in
53-
start)
54-
_status_q && exit 0
55-
$1
56-
;;
57-
stop)
58-
_status_q || exit 0
59-
$1
60-
;;
61-
restart|reload)
62-
restart
63-
;;
64-
status)
65-
_status
66-
;;
67-
status_q)
68-
_status_q
69-
;;
70-
condrestart|try-restart)
71-
_status_q || exit 7
72-
restart
73-
;;
74-
*)
75-
echo $"Usage: $0 {start|stop|reload|status|restart}"
76-
exit 2
63+
start)
64+
_status_q && exit 0
65+
$1
66+
;;
67+
stop)
68+
_status_q || exit 0
69+
$1
70+
;;
71+
restart | reload)
72+
restart
73+
;;
74+
status)
75+
_status
76+
;;
77+
status_q)
78+
_status_q
79+
;;
80+
condrestart | try-restart)
81+
_status_q || exit 7
82+
restart
83+
;;
84+
*)
85+
echo $"Usage: $0 {start|stop|reload|status|restart}"
86+
exit 2
87+
;;
7788
esac

0 commit comments

Comments
 (0)