Improve quoting.

This commit is contained in:
Darko Poljak 2018-10-10 12:52:50 +02:00
parent 8669ccb9c1
commit 610deba454

View file

@ -10,74 +10,75 @@
# pidfile: /var/run/consul-template/pidfile
# Source function library.
# shellcheck disable=SC1091
. /etc/init.d/functions
NAME=consul-template
CONSUL_TEMPLATE=/usr/local/bin/consul-template
CONFIG=/etc/$NAME/conf.d
PID_FILE=/var/run/$NAME/pidfile
LOG_FILE=/var/log/$NAME
CONFIG="/etc/$NAME/conf.d"
PID_FILE="/var/run/$NAME/pidfile"
LOG_FILE="/var/log/$NAME"
# shellcheck disable=SC1090
[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
export CONSUL_TEMPLATE_LOG=${CONSUL_TEMPLATE_LOG:-info}
export GOMAXPROCS=${GOMAXPROCS:-2}
[ -e "/etc/sysconfig/$NAME" ] && . "/etc/sysconfig/$NAME"
export CONSUL_TEMPLATE_LOG="${CONSUL_TEMPLATE_LOG:-info}"
export GOMAXPROCS="${GOMAXPROCS:-2}"
mkdir -p /var/run/$NAME
mkdir -p "/var/run/$NAME"
start() {
printf "Starting %s" "$NAME: "
printf "Starting %s: " "$NAME"
daemon --pidfile="$PID_FILE" \
"$CONSUL_TEMPLATE" -config "$CONFIG" >> "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "$!" > "$PID_FILE"
retcode=$?
touch /var/lock/subsys/$NAME
return $retcode
touch "/var/lock/subsys/$NAME"
return "$retcode"
}
stop() {
printf "Shutting down %s" "$NAME: "
killproc -p $PID_FILE $CONSUL_TEMPLATE
printf "Shutting down %s: " "$NAME"
killproc -p "$PID_FILE" "$CONSUL_TEMPLATE"
retcode=$?
rm -f /var/lock/subsys/$NAME
return $retcode
rm -f "/var/lock/subsys/$NAME"
return "$retcode"
}
case "$1" in
start)
if status -p "$PID_FILE" $NAME >/dev/null; then
if status -p "$PID_FILE" "$NAME" >/dev/null; then
echo "$NAME already running"
else
start
fi
;;
stop)
if status -p "$PID_FILE" $NAME >/dev/null; then
if status -p "$PID_FILE" "$NAME" >/dev/null; then
stop
else
echo "$NAME not running"
fi
;;
status)
status -p "$PID_FILE" $NAME
status -p "$PID_FILE" "$NAME"
exit $?
;;
restart)
if status -p "$PID_FILE" $NAME >/dev/null; then
if status -p "$PID_FILE" "$NAME" >/dev/null; then
stop
fi
start
;;
reload)
if status -p "$PID_FILE" $NAME >/dev/null; then
if status -p "$PID_FILE" "$NAME" >/dev/null; then
kill -HUP "$(cat "$PID_FILE")"
else
echo "$NAME not running"
fi
;;
condrestart)
if [ -f /var/lock/subsys/$NAME ]; then
if status -p "$PID_FILE" $NAME >/dev/null; then
if [ -f "/var/lock/subsys/$NAME" ]; then
if status -p "$PID_FILE" "$NAME" >/dev/null; then
stop
fi
start