Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# |
3 |
# $FreeBSD: head/textproc/elasticsearch6/files/elasticsearch.in 513796 2019-10-05 00:09:16Z glewis $ |
4 |
# |
5 |
# PROVIDE: elasticsearch |
6 |
# REQUIRE: NETWORKING SERVERS |
7 |
# BEFORE: DAEMON |
8 |
# KEYWORD: shutdown |
9 |
# |
10 |
# Add the following line to /etc/rc.conf to enable elasticsearch: |
11 |
# |
12 |
# elasticsearch_enable="YES" |
13 |
# |
14 |
# elasticsearch_user (username): Set to elasticsearch by default. |
15 |
# Set it to required username. |
16 |
# elasticsearch_group (group): Set to elasticsearch by default. |
17 |
# Set it to required group. |
18 |
# elasticsearch_config (path): Set to %%PREFIX%%/etc/elasticsearch/elasticsearch.yml by default. |
19 |
# Set it to the config file location. |
20 |
# elasticsearch_java_home (path): Set to %%JAVA_HOME%% by default. |
21 |
# Set it to the root of the JDK to use. |
22 |
# |
23 |
. /etc/rc.subr |
24 |
|
25 |
name=elasticsearch |
26 |
rcvar=elasticsearch_enable |
27 |
|
28 |
load_rc_config ${name} |
29 |
|
30 |
: ${elasticsearch_enable:=NO} |
31 |
: ${elasticsearch_user=elasticsearch} |
32 |
: ${elasticsearch_group=elasticsearch} |
33 |
: ${elasticsearch_config=%%PREFIX%%/etc/elasticsearch} |
34 |
: ${elasticsearch_login_class=root} |
35 |
: ${elasticsearch_java_home="%%JAVA_HOME%%"} |
36 |
|
37 |
required_files="${elasticsearch_config}/elasticsearch.yml" |
38 |
_pidprefix=/var/run/elasticsearch/elasticsearch |
39 |
pidfile=${_pidprefix}.pid |
40 |
procname=${elasticsearch_java_home}/bin/java |
41 |
|
42 |
extra_commands="console status" |
43 |
console_cmd=elasticsearch_console |
44 |
start_precmd=elasticsearch_precmd |
45 |
command=%%PREFIX%%/lib/elasticsearch/bin/elasticsearch |
46 |
command_args="-d --pidfile=${pidfile}" |
47 |
|
48 |
export ES_PATH_CONF=${elasticsearch_config} |
49 |
export JAVA_HOME=${elasticsearch_java_home} |
50 |
|
51 |
elasticsearch_precmd() |
52 |
{ |
53 |
/usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 ${pidfile%/*} |
54 |
/usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 /var/db/elasticsearch |
55 |
/usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 /var/log/elasticsearch |
56 |
} |
57 |
|
58 |
elasticsearch_console() |
59 |
{ |
60 |
command_args="" |
61 |
run_rc_command "start" |
62 |
} |
63 |
|
64 |
if [ -n "$2" ]; then |
65 |
profile="$2" |
66 |
if [ "x${elasticsearch_profiles}" != "x" ]; then |
67 |
eval elasticsearch_config="\${elasticsearch_${profile}_config:-}" |
68 |
if [ "x${elasticsearch_config}" = "x" ]; then |
69 |
echo "You must define a configuration (elasticsearch_${profile}_config)" |
70 |
exit 1 |
71 |
fi |
72 |
export ES_PATH_CONF=${elasticsearch_config} |
73 |
required_files="${elasticsearch_config}/elasticsearch.yml" |
74 |
required_files="${elasticsearch_config}/jvm.options" |
75 |
eval elasticsearch_enable="\${elasticsearch_${profile}_enable:-${elasticsearch_enable}}" |
76 |
pidfile="${_pidprefix}.${profile}.pid" |
77 |
command_args="-d --pidfile=${pidfile}" |
78 |
echo "===> elasticsearch profile: ${profile}" |
79 |
else |
80 |
echo "$0: extra argument ignored" |
81 |
fi |
82 |
else |
83 |
if [ "x${elasticsearch_profiles}" != "x" -a "x$1" != "x" ]; then |
84 |
for profile in ${elasticsearch_profiles}; do |
85 |
eval _enable="\${elasticsearch_${profile}_enable}" |
86 |
case "x${_enable:-${elasticsearch_enable}}" in |
87 |
x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee]) |
88 |
continue |
89 |
;; |
90 |
x[Yy][Ee][Ss]) |
91 |
;; |
92 |
*) |
93 |
if test -z "$_enable"; then |
94 |
_var=elasticsearch_enable |
95 |
else |
96 |
_var=elasticsearch_"${profile}"_enable |
97 |
fi |
98 |
echo "Bad value" \ |
99 |
"'${_enable:-${elasticsearch_enable}}'" \ |
100 |
"for ${_var}. " \ |
101 |
"Profile ${profile} skipped." |
102 |
continue |
103 |
;; |
104 |
esac |
105 |
%%PREFIX%%/etc/rc.d/elasticsearch $1 ${profile} |
106 |
retcode="$?" |
107 |
if [ "0${retcode}" -ne 0 ]; then |
108 |
failed="${profile} (${retcode}) ${failed:-}" |
109 |
else |
110 |
success="${profile} ${success:-}" |
111 |
fi |
112 |
done |
113 |
exit 0 |
114 |
fi |
115 |
fi |
116 |
|
117 |
if [ "x${elasticsearch_mem_min}" != "x" ]; then |
118 |
echo "The elasticsearch_mem_min variable is no longer supported please set this in %%PREFIX%%/etc/jvm.options" |
119 |
exit 1; |
120 |
fi |
121 |
if [ "x${elasticsearch_mem_max}" != "x" ]; then |
122 |
echo "The elasticsearch_mem_max variable is no longer supported please set this in %%PREFIX%%/etc/jvm.options" |
123 |
exit 1; |
124 |
fi |
125 |
if [ "x${elasticsearch_props}" != "x" ]; then |
126 |
echo "The elasticsearch_props variable is no longer supported please set this in %%PREFIX%%/etc/jvm.options" |
127 |
exit 1; |
128 |
fi |
129 |
|
130 |
run_rc_command "$1" |