From a8ca8410a8ccda513976ff14244bc5278ed228b2 Mon Sep 17 00:00:00 2001 From: yo Date: Mon, 16 May 2022 10:50:52 +0200 Subject: [PATCH] Service handles rights on pid and logfile --- files/mynettcptable.in | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/files/mynettcptable.in b/files/mynettcptable.in index 5fece35..14a4bcd 100644 --- a/files/mynettcptable.in +++ b/files/mynettcptable.in @@ -29,12 +29,23 @@ load_rc_config $name : ${mynettcptable_enable="NO"} : ${mynettcptable_config="/usr/local/etc/mynettcptable.conf"} : ${mynettcptable_loglevel="warn"} -: ${mynettcptable_user:="mynettcptable"} -: ${mynettcptable_pidfile:="/var/run/mynettcptable.pid"} +: ${mynettcptable_user:="nobody"} : ${mynettcptable_logfile="/var/log/mynettcptable.log"} -command="/usr/local/bin/mynettcptable" -command_args="-config=\${mynettcptable_config} -logLevel=\${mynettcptable_loglevel} -logLevel=\${mynettcptable_loglevel} > ${mynettcptable_logfile} 2>&1" -start_cmd="/usr/sbin/daemon -u ${mynettcptable_user} ${command} ${command_args}" +pidfile="/var/run/${name}/${name}.pid" +mynettcptable_command="/usr/local/bin/mynettcptable" + +start_precmd="mynettcptable_prestart" +command="/usr/sbin/daemon" +command_args="-P ${pidfile} -u ${mynettcptable_user} -r -f ${mynettcptable_command} -config=${mynettcptable_config} -logLevel=${mynettcptable_loglevel} -logLevel=${mynettcptable_loglevel} >> ${mynettcptable_logfile} 2>&1" + +mynettcptable_prestart() +{ + mkdir /var/run/${name} >/dev/null 2>&1 + touch ${mynettcptable_logfile} + chown ${mynettcptable_user} /var/run/${name} + chown ${mynettcptable_user} ${mynettcptable_logfile} +} run_rc_command "$1" +