rewrite of service script
This commit is contained in:
parent
f0ad1a91cb
commit
8722786e8e
@ -7,6 +7,9 @@
|
||||
# KEYWORD: shutdown
|
||||
#
|
||||
# isso_enable="YES"
|
||||
# isso_bin="/usr/local/bin/isso"
|
||||
# isso_config="/usr/local/etc/isso.conf"
|
||||
# isso_user="www"
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
@ -18,43 +21,54 @@ desc="isso commenting service"
|
||||
load_rc_config ${name}
|
||||
|
||||
: ${isso_enable:=NO}
|
||||
: ${isso_bin=/usr/local/bin/isso}
|
||||
: ${isso_config=/usr/local/etc/isso.conf}
|
||||
: ${isso_user=www}
|
||||
|
||||
logfile=/var/log/isso.log
|
||||
pidfile=/var/run/isso.pid
|
||||
command=/usr/local/bin/isso
|
||||
command="${isso_bin} -c ${isso_config} run"
|
||||
start_cmd=isso_start
|
||||
status_cmd=isso_status
|
||||
stop_cmd=isso_stop
|
||||
procname=/usr/sbin/daemon
|
||||
|
||||
is_process_running="[ -f $pidfile ] && procstat $(cat $pidfile) >/dev/null 2>&1"
|
||||
|
||||
isso_start()
|
||||
{
|
||||
if is_process_running; then
|
||||
echo "isso is already running (pid=$(cat $pidfile))"
|
||||
if [ -f ${pidfile} ]; then
|
||||
echo "isso is already running (pid=$(cat ${pidfile}))"
|
||||
return 1
|
||||
fi
|
||||
export USER=www
|
||||
export HOME=$(echo ~www)
|
||||
touch $logfile
|
||||
chmod 640 $logfile
|
||||
/usr/sbin/daemon -P $pidfile -u www /usr/local/bin/isso -c ${isso_config} run >>$logfile 2>&1
|
||||
if is_process_running; then
|
||||
echo "started isso (pid=$(cat $pidfile))"
|
||||
export USER=${isso_user}
|
||||
export HOME=$(echo ~${isso_user})
|
||||
touch ${logfile}
|
||||
chmod 640 ${logfile}
|
||||
${procname} -P ${pidfile} -u ${isso_user} ${command} >>${logfile} 2>&1
|
||||
if [ -f ${pidfile} ]; then
|
||||
echo "started isso (pid=$(cat ${pidfile}))"
|
||||
else
|
||||
echo "failed to start isso"
|
||||
fi
|
||||
}
|
||||
|
||||
isso_status()
|
||||
{
|
||||
if [ -f ${pidfile} ]; then
|
||||
echo "isso is running (pid=$(cat ${pidfile}))"
|
||||
else
|
||||
echo "isso is not running"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
isso_stop()
|
||||
{
|
||||
if is_process_running; then
|
||||
if [ -f ${pidfile} ]; then
|
||||
local pid=$(cat $pidfile)
|
||||
echo "stopping isso (pid=$pid)"
|
||||
kill -- -$pid
|
||||
else
|
||||
echo "isso isn't running"
|
||||
echo "isso is not running"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user