Browse Source

Refactor the rc script

pull/105/head
Rodolphe Bréard 1 year ago
parent
commit
4235f417e9
  1. 35
      contrib/rc.d/acmed
  2. 37
      contrib/rc.d/acmed.in

35
contrib/rc.d/acmed

@ -1,35 +0,0 @@
#!/bin/sh
# PROVIDE: acmed
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
. /etc/rc.subr
name="acmed"
rcvar="${name}_enable"
pidfile="/var/run/${name}.pid"
acmed_config_file="/usr/local/etc/acmed/acmed.toml"
required_files="${acmed_config_file}"
command="/usr/local/bin/${name}"
start_precmd="${name}_prestart"
load_rc_config "$name"
: ${acmed_enable:=no}
: ${acmed_log_level:="info"}
: ${acmed_root_cert:=}
acmed_prestart()
{
if [ "$acmed_root_cert" != "" ]; then
rc_flags="--root-cert ${acmed_root_cert} ${rc_flags}"
fi
if [ "$acmed_log_level" != "" ]; then
rc_flags="--log-level ${acmed_log_level} ${rc_flags}"
fi
rc_flags="--log-syslog ${rc_flags}"
rc_flags="--pid-file ${pidfile} ${rc_flags}"
rc_flags="--config ${acmed_config_file} ${rc_flags}"
}
run_rc_command "$1"

37
contrib/rc.d/acmed.in

@ -0,0 +1,37 @@
#!/bin/sh
# PROVIDE: acmed
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable acmed:
# acmed_enable (bool): Set it to "YES" to enable ACMEd.
# Default is "NO".
# acmed_config (string): Path to ACMEd configuration file.
# Default is "%%PREFIX%%/etc/acmed/acmed.toml".
# acmed_log_level (string): Set the log verbosity level.
# Possible values are "error", "warn", "info",
# "debug" and "trace".
# Default is "info".
# acmed_flags (string): Additional flags to be passed to acmed.
# Default is "--log-syslog".
#
. /etc/rc.subr
name="acmed"
rcvar="${name}_enable"
load_rc_config "$name"
: ${acmed_enable:="NO"}
: ${acmed_config:="%%PREFIX%%/etc/acmed/acmed.toml"}
: ${acmed_log_level:="info"}
: ${acmed_flags:="--log-syslog"}
pidfile="/var/run/${name}.pid"
command="/usr/local/bin/${name}"
command_args="--config ${acmed_config} --pid-file ${pidfile} --log-level ${acmed_log_level} ${command_args}"
required_files="${acmed_config}"
run_rc_command "$1"
Loading…
Cancel
Save