baresip: rely on procd for shutdown
No need to stop baresip manually. Just let procd handle it. Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
parent
0eb7795080
commit
c6509afd2b
1 changed files with 0 additions and 52 deletions
|
@ -12,7 +12,6 @@ DEFAULT=/etc/default/$DAEMON
|
|||
LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON"
|
||||
OPTIONS=
|
||||
PROG=/usr/bin/$DAEMON
|
||||
TIMEOUT=30
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
|
||||
|
@ -38,54 +37,3 @@ start_service() {
|
|||
procd_set_param user $DAEMON
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
local retval=
|
||||
local mypid=
|
||||
local timeout=$TIMEOUT
|
||||
|
||||
pgrep $DAEMON &> /dev/null
|
||||
[ $? -ne 0 ] && exit 0
|
||||
|
||||
[ -f /var/run/${DAEMON}.pid ]
|
||||
retval=$?
|
||||
|
||||
# init script could find itself in a scenario where baresip was started
|
||||
# very recently, so make it wait a while for a pid file to appear
|
||||
while [ $retval -ne 0 -a $timeout -gt 0 ]; do
|
||||
sleep 1
|
||||
[ -f /var/run/${DAEMON}.pid ]
|
||||
retval=$?
|
||||
timeout=$(($timeout-1))
|
||||
done
|
||||
|
||||
[ $retval -eq 0 ] || {
|
||||
$LOGGER PID file does not exist
|
||||
exit 1
|
||||
}
|
||||
|
||||
mypid=$(cat /var/run/${DAEMON}.pid)
|
||||
|
||||
[ "$mypid" -gt 1 ] 2> /dev/null || {
|
||||
$LOGGER PID file contains garbage
|
||||
exit 1
|
||||
}
|
||||
|
||||
timeout=$TIMEOUT
|
||||
kill $mypid 2>/dev/null
|
||||
pgrep $DAEMON | grep -w $mypid &>/dev/null
|
||||
retval=$?
|
||||
|
||||
while [ $retval -eq 0 -a $timeout -gt 0 ]; do
|
||||
sleep 10
|
||||
pgrep $DAEMON | grep -w $mypid &>/dev/null
|
||||
retval=$?
|
||||
[ $retval -eq 0 ] && kill $mypid 2>/dev/null
|
||||
timeout=$(($timeout-10))
|
||||
done
|
||||
|
||||
[ $retval -ne 1 ] && {
|
||||
$LOGGER Failed to stop $DAEMON
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue