Skip to content

Instantly share code, notes, and snippets.

@digizeph
Created December 4, 2017 01:41
Show Gist options
  • Select an option

  • Save digizeph/d1f8eb868b7193e1b0341f0cd52f8ba7 to your computer and use it in GitHub Desktop.

Select an option

Save digizeph/d1f8eb868b7193e1b0341f0cd52f8ba7 to your computer and use it in GitHub Desktop.
Simple template for freebsd rc script
#!/bin/sh
. /etc/rc.subr
name=gobgp
rcvar=gobgp_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
stop_postcmd="${name}_cleanup"
pidfile=/var/run/gobgp.pid
load_rc_config $name
: ${gobgp_enable:=no}
: ${gobgp_msg="Nothing started."}
gobgp_start()
{
echo "Starting GOBGP"
touch ${pidfile}
/usr/sbin/daemon -cf -p ${pidfile} /usr/local/bin/gobgp
}
gobgp_stop()
{
echo "Stopping GOBGP"
pkill $name
}
gobgp_cleanup() {
[ -f ${pidfile} ] && rm ${pidfile}
}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment