1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-22 08:42:32 -05:00

Debian's Init.d workaround for loading user's environment variables with start-stop-daemon command.

Implies 2 running child, so the `stop` command usually needs a `KILL` instead of a `TERM` to close properly so I reduced it to 1 second to get quickly with the `KILL` signal.
This commit is contained in:
Danny B 2014-09-30 21:30:16 -04:00
parent f7de6d2b86
commit 98c719c342

View file

@ -31,11 +31,6 @@ USER=git
# Exit if the package is not installed # Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0 [ -x "$DAEMON" ] || exit 0
# Prepare the starting daemon command depending on available non-mandatory variables
STARTDEAMONEVALOPTS=""
[ ! -z "$USER" ] && STARTDEAMONEVALOPTS="$STARTDEAMONEVALOPTS --chuid $USER "
[ ! -z "$WORKINGDIR" ] && STARTDEAMONEVALOPTS="$STARTDEAMONEVALOPTS --chdir \"$WORKINGDIR\" "
# Load the VERBOSE setting and other rcS variables # Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh . /lib/init/vars.sh
@ -54,10 +49,10 @@ do_start()
# 1 if daemon was already running # 1 if daemon was already running
# 2 if daemon could not be started # 2 if daemon could not be started
sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
$STARTDEAMONEVALOPTS --exec $DAEMON -- $DAEMON_ARGS --test > /dev/null \\ --exec $DAEMON -- $DAEMON_ARGS --test > /dev/null \\
|| return 1" || return 1"
sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
$STARTDEAMONEVALOPTS --background --exec $DAEMON -- $DAEMON_ARGS \\ --background --exec /bin/su -- - $USER -c \"cd \\\"$WORKINGDIR\\\" && $DAEMON -- $DAEMON_ARGS\" \\
|| return 2" || return 2"
} }
@ -71,10 +66,10 @@ do_stop()
# 1 if daemon was already stopped # 1 if daemon was already stopped
# 2 if daemon could not be stopped # 2 if daemon could not be stopped
# other if a failure occurred # other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?" RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2 [ "$RETVAL" = 2 ] && return 2
start-stop-daemon --stop --quiet --oknodo --retry=0/10/KILL/5 --exec $DAEMON start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2 [ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit. # Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE rm -f $PIDFILE