Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: opensearch |
4 |
# REQUIRE: DAEMON |
5 |
# BEFORE: LOGIN |
6 |
# KEYWORD: shutdown |
7 |
# |
8 |
# Add the following line to /etc/rc.conf to enable opensearch: |
9 |
# |
10 |
# opensearch_enable="YES" |
11 |
# |
12 |
# opensearch_user (username): Set to opensearch by default. |
13 |
# Set it to required username. |
14 |
# opensearch_group (group): Set to opensearch by default. |
15 |
# Set it to required group. |
16 |
# opensearch_config (path): Set to %%PREFIX%%/etc/opensearch/opensearch.yml by default. |
17 |
# Set it to the config file location. |
18 |
# opensearch_java_home (path): Set to %%JAVA_HOME%% by default. |
19 |
# Set it to the root of the JDK to use. |
20 |
# |
21 |
. /etc/rc.subr |
22 |
|
23 |
name=opensearch |
24 |
rcvar=opensearch_enable |
25 |
|
26 |
load_rc_config ${name} |
27 |
|
28 |
: ${opensearch_enable:=NO} |
29 |
: ${opensearch_user=opensearch} |
30 |
: ${opensearch_group=opensearch} |
31 |
: ${opensearch_config=%%PREFIX%%/etc/opensearch} |
32 |
: ${opensearch_login_class=root} |
33 |
: ${opensearch_java_home="%%JAVA_HOME%%"} |
34 |
|
35 |
required_files="${opensearch_config}/opensearch.yml" |
36 |
_pidprefix=/var/run/opensearch/opensearch |
37 |
pidfile=${_pidprefix}.pid |
38 |
procname=${opensearch_java_home}/bin/java |
39 |
|
40 |
extra_commands="console status" |
41 |
console_cmd=opensearch_console |
42 |
start_precmd=opensearch_precmd |
43 |
command=%%PREFIX%%/lib/opensearch/bin/opensearch |
44 |
command_args="-d --pidfile=${pidfile}" |
45 |
|
46 |
export OPENSEARCH_PATH_CONF=${opensearch_config} |
47 |
export OPENSEARCH_JAVA_HOME=${opensearch_java_home} |
48 |
|
49 |
opensearch_precmd() |
50 |
{ |
51 |
/usr/bin/install -d -o ${opensearch_user} -g ${opensearch_group} -m 755 ${pidfile%/*} |
52 |
/usr/bin/install -d -o ${opensearch_user} -g ${opensearch_group} -m 755 /var/db/opensearch |
53 |
/usr/bin/install -d -o ${opensearch_user} -g ${opensearch_group} -m 755 /var/log/opensearch |
54 |
} |
55 |
|
56 |
opensearch_console() |
57 |
{ |
58 |
command_args="" |
59 |
run_rc_command "start" |
60 |
} |
61 |
|
62 |
if [ -n "$2" ]; then |
63 |
profile="$2" |
64 |
if [ "x${opensearch_profiles}" != "x" ]; then |
65 |
eval opensearch_config="\${opensearch_${profile}_config:-}" |
66 |
if [ "x${opensearch_config}" = "x" ]; then |
67 |
echo "You must define a configuration (opensearch_${profile}_config)" |
68 |
exit 1 |
69 |
fi |
70 |
export OPENSEARCH_PATH_CONF=${opensearch_config} |
71 |
required_files="${opensearch_config}/opensearch.yml" |
72 |
required_files="${opensearch_config}/jvm.options" |
73 |
eval opensearch_enable="\${opensearch_${profile}_enable:-${opensearch_enable}}" |
74 |
pidfile="${_pidprefix}.${profile}.pid" |
75 |
command_args="-d --pidfile=${pidfile}" |
76 |
echo "===> opensearch profile: ${profile}" |
77 |
else |
78 |
echo "$0: extra argument ignored" |
79 |
fi |
80 |
else |
81 |
if [ "x${opensearch_profiles}" != "x" -a "x$1" != "x" ]; then |
82 |
for profile in ${opensearch_profiles}; do |
83 |
eval _enable="\${opensearch_${profile}_enable}" |
84 |
case "x${_enable:-${opensearch_enable}}" in |
85 |
x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee]) |
86 |
continue |
87 |
;; |
88 |
x[Yy][Ee][Ss]) |
89 |
;; |
90 |
*) |
91 |
if test -z "$_enable"; then |
92 |
_var=opensearch_enable |
93 |
else |
94 |
_var=opensearch_"${profile}"_enable |
95 |
fi |
96 |
echo "Bad value" \ |
97 |
"'${_enable:-${opensearch_enable}}'" \ |
98 |
"for ${_var}. " \ |
99 |
"Profile ${profile} skipped." |
100 |
continue |
101 |
;; |
102 |
esac |
103 |
%%PREFIX%%/etc/rc.d/opensearch $1 ${profile} |
104 |
retcode="$?" |
105 |
if [ "0${retcode}" -ne 0 ]; then |
106 |
failed="${profile} (${retcode}) ${failed:-}" |
107 |
else |
108 |
success="${profile} ${success:-}" |
109 |
fi |
110 |
done |
111 |
exit 0 |
112 |
fi |
113 |
fi |
114 |
|
115 |
run_rc_command "$1" |