-
-
Save pboesch/721ab95c8ec52b1d0047af4b2b88999c to your computer and use it in GitHub Desktop.
FreeBSD rc.d script for isso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# PROVIDE: isso | |
# REQUIRE: networking | |
# KEYWORD: shutdown | |
# | |
# Add the following lines to /etc/rc.conf to enable isso: | |
# | |
# isso_enable (bool): Set to "NO" by default. | |
# Set it to "YES" to enable isso. | |
# | |
# isso_config_path (str): Set to "/etc/isso.conf" by default. | |
# | |
# isso_bin_path (str): Set to "/usr/local/bin/isso" by default. | |
# | |
# isso_run_user (str): Set to "www" by default. | |
# Defines the user that isso will run on | |
# | |
. /etc/rc.subr | |
name="isso" | |
rcvar="${name}_enable" | |
load_rc_config $name | |
: ${isso_enable:=no} | |
: ${isso_config_path="/usr/local/etc/isso.conf"} | |
: ${isso_bin_path="/usr/local/bin/isso"} | |
: ${isso_run_user="isso"} | |
pidfile="/var/run/isso.pid" | |
command="${isso_bin_path} -c ${isso_config_path}" | |
start_cmd="isso_start" | |
status_cmd="isso_status" | |
stop_cmd="isso_stop" | |
isso_start() { | |
echo "Starting ${name}..." | |
/usr/sbin/daemon -c -u ${isso_run_user} -p ${pidfile} ${command} | |
} | |
isso_status() { | |
if [ -f ${pidfile} ]; then | |
echo "${name} is running as $(cat $pidfile)." | |
else | |
echo "${name} is not running." | |
return 1 | |
fi | |
} | |
isso_stop() { | |
if [ ! -f ${pidfile} ]; then | |
echo "${name} is not running." | |
return 1 | |
fi | |
echo -n "Stopping ${name}..." | |
kill -KILL $(cat $pidfile) 2> /dev/null && echo "stopped" | |
rm -f ${pidfile} | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment