mirror of
https://github.com/bol-van/zapret.git
synced 2025-04-19 21:42:59 +03:00
sysv init : simplify daemon launch. remove nohup
This commit is contained in:
parent
4327fc6976
commit
198225bc4f
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# For systemd :
|
# For systemd :
|
||||||
# install : /usr/lib/lsb/install_initd zapret
|
# install : /usr/lib/lsb/install_initd zapret
|
||||||
# remove : /usr/lib/lsb/remove_initd zapret
|
# remove : /usr/lib/lsb/remove_initd zapret
|
||||||
@ -96,7 +96,6 @@ fw_nfqws_del_post()
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
JOBCT=1
|
|
||||||
run_daemon()
|
run_daemon()
|
||||||
{
|
{
|
||||||
# $1 - daemon number : 1,2,3,...
|
# $1 - daemon number : 1,2,3,...
|
||||||
@ -107,16 +106,15 @@ run_daemon()
|
|||||||
local PIDFILE=$PIDDIR/$DAEMONBASE$1.pid
|
local PIDFILE=$PIDDIR/$DAEMONBASE$1.pid
|
||||||
echo "Starting daemon $1: $2 $3"
|
echo "Starting daemon $1: $2 $3"
|
||||||
if exists start-stop-daemon ; then
|
if exists start-stop-daemon ; then
|
||||||
start-stop-daemon --start --pidfile "$PIDFILE" --background --make-pidfile --exec "$2" -- $3 || true
|
start-stop-daemon --start --pidfile "$PIDFILE" --background --make-pidfile --exec "$2" -- $3
|
||||||
else
|
else
|
||||||
if [ -f "$PIDFILE" ] && pgrep -F "$PIDFILE" "$DAEMONBASE" >/dev/null; then
|
if [ -f "$PIDFILE" ] && pgrep -F "$PIDFILE" "$DAEMONBASE" >/dev/null; then
|
||||||
echo already running
|
echo already running
|
||||||
else
|
else
|
||||||
nohup "$2" $3 >/dev/null 2>/dev/null &
|
"$2" $3 >/dev/null 2>/dev/null &
|
||||||
PID=$(jobs -p %$JOBCT)
|
PID=$!
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
echo $PID >$PIDFILE
|
echo $PID >$PIDFILE
|
||||||
JOBCT=$(($JOBCT+1))
|
|
||||||
else
|
else
|
||||||
echo could not start daemon $1 : $2 $3
|
echo could not start daemon $1 : $2 $3
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user