blob: 6151d3e213996e34bb1a731856bca10e0575831b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/sh
# PROVIDE: qdrant
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to run qdrant:
#
# qdrant_profiles (str): Set to "" by default.
# Define your profiles here.
# qdrant(_profile)?_enable (bool): Set it to "YES" to enable qdrant.
# Default is "NO".
# qdrant(_profile)?_config (str): Full name of config file
# Default is "%%ETCDIR%%/config.yaml" or
# "%%ETCDIR%%/config(.profile)?.yaml
# qdrant(_profile)?_args (flags): Set extra args here. More options in qdrant(1)
# Default is empty "".
# qdrant(_profile)?_user (user): Set user to run qdrant.
# Default is "nobody".
# qdrant(_profile)?_group (group): Set group to run qdrant.
# Default is "nobody".
# qdrant(_profile)?_post_start (str): Set extra commands that should be executed after qdrant was successfully
# started here.
# Default is empty "".
. /etc/rc.subr
name="qdrant"
rcvar=qdrant_enable
_piddir="/var/run/qdrant"
pidfile="${_piddir}/qdrant.pid"
: ${qdrant_enable="NO"}
: ${qdrant_config="%%ETCDIR%%/config.yaml"}
: ${qdrant_user="nobody"}
: ${qdrant_group="nobody"}
: ${qdrant_args=""}
load_rc_config ${name}
if [ -n "$2" ]; then
profile="$2"
if [ -n "${qdrant_profiles}" ]; then
pidfile="${_piddir}/qdrant.${profile}.pid"
eval qdrant_enable="\${qdrant_${profile}_enable:-${qdrant_enable}}"
eval qdrant_config="\${qdrant_${profile}_config:-${qdrant_config}}"
eval qdrant_user="\${qdrant_${profile}_user:-${qdrant_user}}"
eval qdrant_group="\${qdrant_${profile}_group:-${qdrant_group}}"
eval qdrant_args="\${qdrant_${profile}_args:-${qdrant_args}}"
eval qdrant_post_start="\${qdrant_${profile}_post_start:-${qdrant_post_start}}"
else
echo "%%PREFIX%%/etc/rc.d/qdrant%%RC_SUBR_SUFFIX%%: extra argument ignored"
fi
else
if [ -n "${qdrant_profiles}" -a -n "$1" ]; then
for profile in ${qdrant_profiles}; do
eval _enable="\${qdrant_${profile}_enable}"
case "${_enable:-${qdrant_enable}}" in
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
continue
;;
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
;;
*)
if test -z "$_enable"; then
_var=qdrant_enable
else
_var=qdrant_"${profile}"_enable
fi
warn "Bad value" \
"'${_enable:-${qdrant_enable}}'" \
"for ${_var}. " \
"Profile ${profile} skipped."
continue
;;
esac
echo "===> qdrant profile: ${profile}"
if %%PREFIX%%/etc/rc.d/qdrant%%RC_SUBR_SUFFIX%% $1 ${profile} ; then
success="${profile} ${success:-}"
else
failed="${profile} (${retcode}) ${failed:-}"
fi
done
exit 0
fi
fi
qdrant_poststart()
{
if [ -n "$qdrant_post_start" ]; then
eval $qdrant_post_start
fi
}
qdrant_poststop()
{
if [ -n "${profile}" ]; then
[ -e "$pidfile" ] && unlink $pidfile
else
local file
for file in ${_piddir}/* ; do
case "$file" in
*\*)
continue ;;
esac
unlink $file
done
fi
}
_profsuffx=""
if [ -n "${profile}" ]; then
_profsuffx="-${profile}"
fi
required_files="$qdrant_config"
procname=%%PREFIX%%/bin/qdrant
command="/usr/sbin/daemon"
command_args="-f -S -p ${pidfile} \
-t qdrant${_profsuffx} \
%%PREFIX%%/bin/qdrant --config-path $qdrant_config \
$qdrant_args"
start_precmd="install -d -o $qdrant_user -g $qdrant_group -m 755 $_piddir"
start_postcmd="${name}_poststart"
stop_postcmd="${name}_poststop"
run_rc_command "$1"
|