Lines 10-27
Link Here
|
10 |
# |
10 |
# |
11 |
# Additional variables you can define are: |
11 |
# Additional variables you can define are: |
12 |
# |
12 |
# |
13 |
# consul_user (string): Set user to run consul. |
13 |
# consul_user (string): Set user to run consul. |
14 |
# Default is "%%CONSUL_USER%%". |
14 |
# Default is "%%CONSUL_USER%%". |
15 |
# consul_group (string): Set group to run consul. |
15 |
# consul_group (string): Set group to run consul. |
16 |
# Default is "%%CONSUL_GROUP%%". |
16 |
# Default is "%%CONSUL_GROUP%%". |
17 |
# consul_pidfile (string): Set full path to pid file |
17 |
# consul_configtest (string): Set to yes to enable Consul config validation |
18 |
# Default is "/var/run/consul.pid" |
18 |
# Set to NO by default |
19 |
# consul_configtest (string): Set to yes to enable Consul config validation |
19 |
# consul_datadir (dir): Set dir to run consul in. |
20 |
# Set to NO by default |
20 |
# Default is "%%CONSUL_DATADIR%%" |
21 |
# consul_datadir (dir): Set dir to run consul in. |
|
|
22 |
# Default is "%%CONSUL_DATADIR%%" |
23 |
# consul_syslog_output_enable (bool): Set to YES to enable syslog output |
21 |
# consul_syslog_output_enable (bool): Set to YES to enable syslog output |
24 |
# Default is "NO". See daemon(8). |
22 |
# Default is "NO". See daemon(8). |
|
|
23 |
# consul_syslog_output_tag (str): Set syslog tag if syslog enabled. |
24 |
# Default is "consul". See daemon(8). |
25 |
# consul_syslog_output_priority (str): Set syslog priority if syslog enabled. |
25 |
# consul_syslog_output_priority (str): Set syslog priority if syslog enabled. |
26 |
# Default is "info". See daemon(8). |
26 |
# Default is "info". See daemon(8). |
27 |
# consul_syslog_output_facility (str): Set to YES to enable syslog output |
27 |
# consul_syslog_output_facility (str): Set to YES to enable syslog output |
Lines 41-47
Link Here
|
41 |
: ${consul_syslog_output_enable:="NO"} |
41 |
: ${consul_syslog_output_enable:="NO"} |
42 |
: ${consul_user:="%%CONSUL_USER%%"} |
42 |
: ${consul_user:="%%CONSUL_USER%%"} |
43 |
: ${consul_group:="%%CONSUL_GROUP%%"} |
43 |
: ${consul_group:="%%CONSUL_GROUP%%"} |
44 |
: ${consul_pidfile:="/var/run/${name}.pid"} |
|
|
45 |
: ${consul_configtest:="NO"} |
44 |
: ${consul_configtest:="NO"} |
46 |
: ${consul_datadir:="%%CONSUL_DATADIR%%"} |
45 |
: ${consul_datadir:="%%CONSUL_DATADIR%%"} |
47 |
|
46 |
|
Lines 51-94
Link Here
|
51 |
|
50 |
|
52 |
# backwards compatibility |
51 |
# backwards compatibility |
53 |
if [ -n "${consul_dir}" ]; then |
52 |
if [ -n "${consul_dir}" ]; then |
54 |
consul_datadir=${consul_dir} |
53 |
consul_datadir=${consul_dir} |
55 |
fi |
54 |
fi |
56 |
|
55 |
|
57 |
if checkyesno consul_syslog_output_enable; then |
56 |
if checkyesno consul_syslog_output_enable; then |
58 |
consul_syslog_output_flags="-T ${name}" |
57 |
if [ -n "${consul_syslog_output_tag}" ]; then |
59 |
|
58 |
consul_syslog_output_flags="-T ${consul_syslog_output_tag}" |
60 |
if [ -n "${consul_syslog_output_priority}" ]; then |
59 |
else |
61 |
consul_syslog_output_flags="${consul_syslog_output_flags} -s ${consul_syslog_output_priority}" |
60 |
consul_syslog_output_flags="-T ${name}" |
62 |
fi |
61 |
fi |
63 |
|
62 |
if [ -n "${consul_syslog_output_priority}" ]; then |
64 |
if [ -n "${consul_syslog_output_facility}" ]; then |
63 |
consul_syslog_output_flags="${consul_syslog_output_flags} -s ${consul_syslog_output_priority}" |
65 |
consul_syslog_output_flags="${consul_syslog_output_flags} -l ${consul_syslog_output_facility}" |
64 |
fi |
66 |
fi |
65 |
if [ -n "${consul_syslog_output_facility}" ]; then |
|
|
66 |
consul_syslog_output_flags="${consul_syslog_output_flags} -l ${consul_syslog_output_facility}" |
67 |
fi |
67 |
fi |
68 |
fi |
68 |
|
69 |
|
69 |
if checkyesno consul_configtest; then |
70 |
if checkyesno consul_configtest; then |
70 |
restart_precmd="consul_checkconfig" |
71 |
restart_precmd="consul_checkconfig" |
71 |
reload_precmd="consul_checkconfig" |
72 |
reload_precmd="consul_checkconfig" |
72 |
fi |
73 |
fi |
73 |
|
74 |
|
74 |
pidfile=${consul_pidfile} |
75 |
pidfile="/var/run/${name}/${name}.pid" |
75 |
procname="%%PREFIX%%/bin/consul" |
|
|
76 |
command="/usr/sbin/daemon" |
76 |
command="/usr/sbin/daemon" |
77 |
command_args="-f -t ${name} ${consul_syslog_output_flags} -p ${pidfile} /usr/bin/env ${consul_env} ${procname} agent -data-dir=${consul_datadir} -config-dir=%%ETCDIR%% ${consul_args}" |
77 |
consul_main="/usr/bin/env ${consul_env} %%PREFIX%%/bin/consul agent -data-dir=${consul_datadir} -config-dir=%%ETCDIR%% ${consul_args}" |
|
|
78 |
command_args="-f ${consul_syslog_output_flags} -P ${pidfile} -t ${name} ${consul_main}" |
78 |
|
79 |
|
79 |
consul_start_precmd() |
80 |
consul_start_precmd() |
80 |
{ |
81 |
{ |
81 |
if [ ! -e ${pidfile} ]; then |
82 |
if [ ! -d "/var/run/${name}" ]; then |
82 |
install -o ${consul_user} -g ${consul_group} /dev/null ${pidfile} |
83 |
install -d -m 0750 -o ${consul_user} -g ${consul_group} "/var/run/${name}" |
83 |
fi |
|
|
84 |
|
85 |
if [ ! -d ${consul_datadir} ]; then |
86 |
install -d -m 0750 -o ${consul_user} -g ${consul_group} ${consul_datadir} |
87 |
fi |
88 |
|
89 |
if [ ! -d %%ETCDIR%% ]; then |
90 |
install -d -m 0750 -o ${consul_user} -g ${consul_group} %%ETCDIR%% |
91 |
fi |
84 |
fi |
|
|
85 |
if [ ! -d "${consul_datadir}" ]; then |
86 |
install -d -m 0750 -o ${consul_user} -g ${consul_group} "${consul_datadir}" |
87 |
fi |
88 |
if [ ! -d "%%ETCDIR%%" ]; then |
89 |
install -d -m 0750 -o ${consul_user} -g ${consul_group} "%%ETCDIR%%" |
90 |
fi |
92 |
} |
91 |
} |
93 |
|
92 |
|
94 |
consul_checkconfig() |
93 |
consul_checkconfig() |