From aabb2b600ba17d0e7f1966d078f6cdc9571277ad Mon Sep 17 00:00:00 2001 From: RooHTaylor Date: Wed, 12 Mar 2025 03:35:46 +0000 Subject: [PATCH] Fix init script issues Init.d script contained a space after the `--daemon` flag, which would ultimately become a double space when paired with any of the following flags. The double space would cause the `pgrep` in the `is_running()` function to not find any results, since the double space would be parsed out by the kernel but still exist in the `$DAEMON_OPTS` variable that is being used to grep. When `is_running()` fails the application cannot be stopped, since it doesn't believe it's running. Additionally, on certain versions of Debian there is an issue when running `start-stop-daemon` with a `--pidfile` that is not owned by root. This causes the stop command to fail and an error to be displayed. Include the `--user $RUN_AS` flag as a workaround. --- init/lazylibrarian.initd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/lazylibrarian.initd b/init/lazylibrarian.initd index d146c854..879ce1ee 100755 --- a/init/lazylibrarian.initd +++ b/init/lazylibrarian.initd @@ -69,7 +69,7 @@ load_settings() { return 1; } [ -z "${RUN_AS%:*}" ] && exit 1 - DAEMON_OPTS="LazyLibrarian.py --nolaunch --daemon " + DAEMON_OPTS="LazyLibrarian.py --nolaunch --daemon" [ -n "$CONFIG" ] && DAEMON_OPTS="$DAEMON_OPTS --config=$CONFIG" [ -z "$CONFIG" ] && DAEMON_OPTS="$DAEMON_OPTS --config=/home/$RUN_AS/.lazylibrarian/config.ini" [ -n "$DATADIR" ] && DAEMON_OPTS="$DAEMON_OPTS --datadir=$DATADIR" @@ -121,7 +121,7 @@ start_lazylibrarian () { stop_lazylibrarian () { if is_running; then log_daemon_msg "Stopping $DESC" - start-stop-daemon -o --stop --pidfile $PID_FILE --retry 15 + start-stop-daemon -o --stop --user $RUN_AS --pidfile $PID_FILE --retry 15 check_retval else log_success_msg "$DESC: not running"