mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 21:35:04 +00:00
34 lines
783 B
Text
34 lines
783 B
Text
|
#!/bin/sh
|
||
|
#
|
||
|
# PROVIDE: snac
|
||
|
# REQUIRE: DAEMON
|
||
|
# KEYWORD: shutdown
|
||
|
|
||
|
. /etc/rc.subr
|
||
|
|
||
|
name="snac"
|
||
|
rcvar=${name}
|
||
|
command="/usr/pkg/bin/snac"
|
||
|
command_args="httpd /PATH/TO/SNACDATA"
|
||
|
snac_log="/var/log/snac.log"
|
||
|
pidfile="/var/run/${name}/${name}.pid"
|
||
|
start_precmd="snac_precmd"
|
||
|
run_as_user="SNACUSER"
|
||
|
|
||
|
snac_precmd() {
|
||
|
# Ensure log file exists and is writable by SNACUSER
|
||
|
touch ${snac_log}
|
||
|
chown ${run_as_user} ${snac_log}
|
||
|
chmod 640 ${snac_log}
|
||
|
|
||
|
# Ensure the run directory exists
|
||
|
if [ ! -d /var/run/${name} ]; then
|
||
|
mkdir -p /var/run/${name}
|
||
|
chown ${run_as_user} /var/run/${name}
|
||
|
fi
|
||
|
|
||
|
command="/bin/sh -c 'cd /var/run/${name}; exec ${command} ${command_args} >${snac_log} 2>&1 & echo \$! >${pidfile}'"
|
||
|
}
|
||
|
|
||
|
load_rc_config $name
|
||
|
run_rc_command "$1"
|