Skip to content

Instantly share code, notes, and snippets.

@lastcanal
Created July 4, 2016 17:18
Show Gist options
  • Save lastcanal/fff107dacbf9e08027b1c80a1c085962 to your computer and use it in GitHub Desktop.
Save lastcanal/fff107dacbf9e08027b1c80a1c085962 to your computer and use it in GitHub Desktop.
freebsd libbitcoin-server rc.d script
#!/bin/sh
# $FreeBSD: branches/2016Q2/sysutils/bs/files/bs.in 386655 2015-05-18 02:05:03Z swills $
#
# PROVIDE: bs
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# bs_enable (bool): Set to NO by default.
# Set it to YES to enable bs.
# bs_user (user): Set user to run bs.
# Default is "bs".
# bs_group (group): Set group to run bs.
# Default is "bs".
# bs_dir (dir): Set dir to run bs in.
# Default is "/var/tmp/bs".
# bs_env (dir): Set environment variables used with bs
# Default is "".
. /etc/rc.subr
name=bs
rcvar=bs_enable
load_rc_config $name
: ${bs_enable:="NO"}
: ${bs_user:="bs"}
: ${bs_group:="bs"}
: ${bs_dir:="/var/db/bs"}
: ${bs_env:=""}
pidfile=/var/run/bs.pid
procname="/usr/local/bin/bs"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} /usr/bin/env ${bs_env} ${procname}"
start_precmd=bs_startprecmd
bs_startprecmd()
{
if [ ! -e ${pidfile} ]; then
install -o ${bs_user} -g ${bs_group} /dev/null ${pidfile};
fi
if [ ! -d ${bs_dir} ]; then
install -d -o ${bs_user} -g ${bs_group} ${bs_dir}
fi
}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment