Instantly share code, notes, and snippets.

@pboesch /isso forked from ckoepp/isso
Created Feb 25, 2018

Embed
What would you like to do?
FreeBSD rc.d script for isso
#!/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