Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: openbao |
4 |
# REQUIRE: DAEMON |
5 |
# KEYWORD: shutdown |
6 |
# |
7 |
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf |
8 |
# to enable this service: |
9 |
# |
10 |
# openbao_enable (bool): Set it to YES to enable openbao. |
11 |
# Default is "NO". |
12 |
# openbao_user (user): Set user to run openbao. |
13 |
# Default is "openbao". |
14 |
# openbao_group (group): Set group to run openbao. |
15 |
# Default is "openbao". |
16 |
# openbao_config (file): Set openbao config file. |
17 |
# Default is "%%PREFIX%%/etc/openbao.hcl". |
18 |
# openbao_syslog_output_enable (bool): Set to enable syslog output. |
19 |
# Default is "NO". See daemon(8). |
20 |
# openbao_syslog_output_priority (str): Set syslog priority if syslog enabled. |
21 |
# Default is "info". See daemon(8). |
22 |
# openbao_syslog_output_facility (str): Set syslog facility if syslog enabled. |
23 |
# Default is "daemon". See daemon(8). |
24 |
# openbao_limits_mlock (size): allowd memorylocked value in size. Default is 1024M |
25 |
|
26 |
. /etc/rc.subr |
27 |
|
28 |
name=openbao |
29 |
rcvar=openbao_enable |
30 |
|
31 |
load_rc_config $name |
32 |
|
33 |
: ${openbao_enable:="NO"} |
34 |
: ${openbao_user:="openbao"} |
35 |
: ${openbao_group:="openbao"} |
36 |
: ${openbao_config:="%%PREFIX%%/etc/openbao.hcl"} |
37 |
: ${openbao_limits_mlock:="1024M"} |
38 |
: ${openbao_limits:="-l ${openbao_limits_mlock}"} |
39 |
|
40 |
DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?) |
41 |
if [ ${DAEMON} -eq 0 ]; then |
42 |
: ${openbao_syslog_output_enable:="NO"} |
43 |
: ${openbao_syslog_output_priority:="info"} |
44 |
: ${openbao_syslog_output_facility:="daemon"} |
45 |
if checkyesno openbao_syslog_output_enable; then |
46 |
openbao_syslog_output_flags="-T ${name}" |
47 |
|
48 |
if [ -n "${openbao_syslog_output_priority}" ]; then |
49 |
openbao_syslog_output_flags="${openbao_syslog_output_flags} -s ${openbao_syslog_output_priority}" |
50 |
fi |
51 |
|
52 |
if [ -n "${openbao_syslog_output_facility}" ]; then |
53 |
openbao_syslog_output_flags="${openbao_syslog_output_flags} -l ${openbao_syslog_output_facility}" |
54 |
fi |
55 |
fi |
56 |
else |
57 |
openbao_syslog_output_enable="NO" |
58 |
openbao_syslog_output_flags="" |
59 |
fi |
60 |
|
61 |
pidfile=/var/run/openbao.pid |
62 |
procname="%%PREFIX%%/bin/bao" |
63 |
command="/usr/sbin/daemon" |
64 |
command_args="-f -t ${name} ${openbao_syslog_output_flags} -p ${pidfile} /usr/bin/env ${openbao_env} ${procname} server -config=${openbao_config}" |
65 |
|
66 |
extra_commands="reload monitor" |
67 |
monitor_cmd=openbao_monitor |
68 |
start_precmd=openbao_startprecmd |
69 |
required_files="$openbao_config" |
70 |
|
71 |
openbao_monitor() |
72 |
{ |
73 |
sig_reload=USR1 |
74 |
run_rc_command "reload" |
75 |
} |
76 |
|
77 |
openbao_startprecmd() |
78 |
{ |
79 |
if [ ! -e ${pidfile} ]; then |
80 |
install -o ${openbao_user} -g ${openbao_group} /dev/null ${pidfile}; |
81 |
fi |
82 |
|
83 |
if [ ! -d ${openbao_dir} ]; then |
84 |
install -d -o ${openbao_user} -g ${openbao_group} ${openbao_dir} |
85 |
fi |
86 |
} |
87 |
|
88 |
run_rc_command "$1" |