Addes NetBSD rc script example

This commit is contained in:
Stefano Marinelli 2024-01-07 19:41:43 +00:00
parent c6fa103b40
commit 4d9a19f3bf

34
examples/snac_netbsd Normal file
View file

@ -0,0 +1,34 @@
#!/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"