From 4235f417e9496bc42d6df9b72d239d1f52afaf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 23 Dec 2023 18:57:53 +0100 Subject: [PATCH] Refactor the rc script --- contrib/rc.d/acmed | 35 ----------------------------------- contrib/rc.d/acmed.in | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 35 deletions(-) delete mode 100755 contrib/rc.d/acmed create mode 100755 contrib/rc.d/acmed.in diff --git a/contrib/rc.d/acmed b/contrib/rc.d/acmed deleted file mode 100755 index 31c7c03..0000000 --- a/contrib/rc.d/acmed +++ /dev/null @@ -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" diff --git a/contrib/rc.d/acmed.in b/contrib/rc.d/acmed.in new file mode 100755 index 0000000..7aa84fa --- /dev/null +++ b/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"