create /var/run/consul with permissions suitable for storing unix sockets

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2015-07-23 22:05:55 +02:00
parent 6662535c28
commit b515601c9c
5 changed files with 30 additions and 4 deletions

View file

@ -0,0 +1,9 @@
start on starting consul
task
script
mkdir -p /var/run/consul
chown consul:consul /var/run/consul
chmod 2770 /var/run/consul
end script

View file

@ -7,6 +7,11 @@ After=basic.target network.target
User=consul User=consul
Group=consul Group=consul
Environment="GOMAXPROCS=2" Environment="GOMAXPROCS=2"
# Run ExecStartPre with root-permissions
PermissionsStartOnly=true
ExecStartPre=/usr/bin/mkdir -p /var/run/consul
ExecStartPre=/usr/bin/chown consul:consul /var/run/consul
ExecStartPre=/usr/bin/chmod 2770 /var/run/consul
ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul/conf.d ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul/conf.d
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
KillMode=process KillMode=process

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# 2015 Nico Schottelius (nico-cdist at schottelius.org) # 2015 Nico Schottelius (nico-cdist at schottelius.org)
# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -29,6 +30,10 @@ CONSUL=/usr/local/bin/consul
CONFIG=/etc/$NAME/conf.d CONFIG=/etc/$NAME/conf.d
PID_FILE=/var/run/$NAME/pidfile PID_FILE=/var/run/$NAME/pidfile
mkdir -p /var/run/$NAME
chown consul:consul /var/run/$NAME
chmod 2770 /var/run/$NAME
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in case "$1" in

View file

@ -22,7 +22,9 @@ LOG_FILE=/var/log/$NAME
export GOMAXPROCS=${GOMAXPROCS:-2} export GOMAXPROCS=${GOMAXPROCS:-2}
mkdir -p /var/run/$NAME mkdir -p /var/run/$NAME
chown consul /var/run/$NAME chown consul:consul /var/run/$NAME
chmod 2770 /var/run/$NAME
start() { start() {
echo -n "Starting $NAME: " echo -n "Starting $NAME: "

View file

@ -160,10 +160,15 @@ init_systemd()
init_upstart() init_upstart()
{ {
__file /etc/init/consul.conf \ __file /etc/init/consul-prepare.conf \
--owner root --group root --mode 0644 \ --owner root --group root --mode 0644 \
--state "$state" \ --state "$state" \
--source "$__type/files/consul.upstart" --source "$__type/files/consul-prepare.upstart"
require="__file/etc/init/consul-prepare.conf" \
__file /etc/init/consul.conf \
--owner root --group root --mode 0644 \
--state "$state" \
--source "$__type/files/consul.upstart"
require="__file/etc/init/consul.conf" __start_on_boot consul require="__file/etc/init/consul.conf" __start_on_boot consul
} }