summaryrefslogtreecommitdiff
path: root/sysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in
diff options
context:
space:
mode:
Diffstat (limited to 'sysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in')
-rwxr-xr-xsysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in52
1 files changed, 52 insertions, 0 deletions
diff --git a/sysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in b/sysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in
new file mode 100755
index 000000000000..5c1b08287051
--- /dev/null
+++ b/sysutils/prometheus-smartctl-exporter/files/prometheus-smartctl-exporter.in
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# PROVIDE: prometheus_smartctl_exporter
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# prometheus_smartctl_exporter_enable (bool): Set to NO by default.
+# Set it to YES to enable prometheus_smartctl_exporter.
+# prometheus_smartctl_exporter_user (string): Set user that prometheus_smartctl_exporter will run under
+# Default is "nobody".
+# prometheus_smartctl_exporter_group (string): Set group that prometheus_smartctl_exporter will run under
+# Default is "nobody".
+# prometheus_smartctl_exporter_args (string): Set extra arguments to pass to prometheus_smartctl_exporter
+# Default is "".
+
+. /etc/rc.subr
+
+name=prometheus_smartctl_exporter
+rcvar=prometheus_smartctl_exporter_enable
+
+load_rc_config $name
+
+: ${prometheus_smartctl_exporter_enable:="NO"}
+: ${prometheus_smartctl_exporter_user:="root"}
+: ${prometheus_smartctl_exporter_group:="operator"}
+: ${prometheus_smartctl_exporter_args:=""}
+
+
+pidfile=/var/run/prometheus-smartctl-exporter.pid
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/libexec/prometheus-smartctl-exporter"
+command_args="-f -p ${pidfile} -T ${name} \
+ /usr/bin/env ${procname} \
+ ${prometheus_smartctl_exporter_args}"
+
+start_precmd=prometheus_smartctl_exporter_startprecmd
+
+prometheus_smartctl_exporter_startprecmd()
+{
+ if [ ! -e ${pidfile} ]; then
+ install \
+ -o ${prometheus_smartctl_exporter_user} \
+ -g ${prometheus_smartctl_exporter_group} \
+ /dev/null ${pidfile};
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"