From ef11bf26268d67aa32d9e6cbe50ffcbddb6dacb9 Mon Sep 17 00:00:00 2001 From: Demo User Date: Mon, 10 Jul 2017 18:48:36 +0000 Subject: [PATCH 1/2] allows user associated with script to stop it --- template | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/template b/template index 57d3154..56824a4 100755 --- a/template +++ b/template @@ -9,9 +9,9 @@ # Description: Enable service provided by daemon. ### END INIT INFO -dir="" -cmd="" -user="" +dir="/home/debian" +cmd="python3 $dir/script" +user="debian" name=`basename $0` pid_file="/var/run/$name.pid" @@ -35,10 +35,12 @@ case "$1" in cd "$dir" if [ -z "$user" ]; then sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & + echo $! > "$pid_file" else sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + sleep 1 # process not always started fast enough + echo $(pgrep -U "$user" -xf "$cmd") > "$pid_file" fi - echo $! > "$pid_file" if ! is_running; then echo "Unable to start, see $stdout_log and $stderr_log" exit 1 From 694ffc699813e2eb900d147d884b1c272d038062 Mon Sep 17 00:00:00 2001 From: Demo User Date: Mon, 10 Jul 2017 18:51:16 +0000 Subject: [PATCH 2/2] removed test strings --- template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/template b/template index 56824a4..9dedf0d 100755 --- a/template +++ b/template @@ -9,9 +9,9 @@ # Description: Enable service provided by daemon. ### END INIT INFO -dir="/home/debian" -cmd="python3 $dir/script" -user="debian" +dir="" +cmd="" +user="" name=`basename $0` pid_file="/var/run/$name.pid"