From 75efecfdde0f3925a4e69abdc665d245cfd5c541 Mon Sep 17 00:00:00 2001 From: turint Date: Thu, 31 Jul 2014 15:48:04 +0300 Subject: [PATCH 1/2] Fixes init script start and stop functions. --- resources/install/debian/init.d | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/resources/install/debian/init.d b/resources/install/debian/init.d index 070fd54c49..b8b0784192 100644 --- a/resources/install/debian/init.d +++ b/resources/install/debian/init.d @@ -32,21 +32,32 @@ test -x $DAEMON || exit 0 set -e stop() { + if [ -f $PIDFILE ]; then + PID=$(cat $PIDFILE) + fi echo -n "Stopping $DESC: " - `ps -u $USER -o pid h | xargs kill` - rm $PIDFILE - echo "$NAME." + if [ $PID ]; then + kill $(ps -o pid --no-headers --ppid $PID) + rm $PIDFILE + echo "$NAME stopped." + elif [ $(ps -C jvb.sh h) ]; then + kill $(ps -o pid --no-headers --ppid $(pgrep -o jvb.sh)) + rm $PIDFILE + echo "$NAME stopped." + else + echo "$NAME doesn't seem to be running." + fi } start() { - if [ -x $PIDFILE ]; then - echo "Pidfile $PIDFILE exists. Either Jitsi Videobridge is already running or there was some problem. Investgate before starting." + if [ -f $PIDFILE ]; then + echo "$DESC seems to be already running, we found pidfile $PIDFILE." exit 1 fi echo -n "Starting $DESC: " start-stop-daemon --start --quiet --background --chuid $USER --make-pidfile --pidfile $PIDFILE \ --exec /bin/bash -- -c "exec $DAEMON $DAEMON_OPTS < /dev/null >> $LOGFILE 2>&1" - echo "$NAME." + echo "$NAME started." } reload() { From 2a53aec994a5e92ad4072b2da9b322f6bc6c5cbd Mon Sep 17 00:00:00 2001 From: turint Date: Thu, 31 Jul 2014 16:15:46 +0300 Subject: [PATCH 2/2] Fixes bugs in stop function. Relies on ps only and not on pgrep. --- resources/install/debian/init.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/install/debian/init.d b/resources/install/debian/init.d index b8b0784192..81239ccc80 100644 --- a/resources/install/debian/init.d +++ b/resources/install/debian/init.d @@ -38,11 +38,11 @@ stop() { echo -n "Stopping $DESC: " if [ $PID ]; then kill $(ps -o pid --no-headers --ppid $PID) - rm $PIDFILE + rm $PIDFILE || true echo "$NAME stopped." - elif [ $(ps -C jvb.sh h) ]; then - kill $(ps -o pid --no-headers --ppid $(pgrep -o jvb.sh)) - rm $PIDFILE + elif [ $(ps -C jvb.sh --no-headers -o pid) ]; then + kill $(ps -o pid --no-headers --ppid $(ps -C jvb.sh --no-headers -o pid)) + rm $PIDFILE || true echo "$NAME stopped." else echo "$NAME doesn't seem to be running."