cdist-contrib/gencode-remote
Evilham c5929f397d [__single_binary_service] Adapt bug fixes proposed by pedro
there are several typos, some style issues and now there is at most one service
restart in all cases.

Submitted by:   pedro <git2021@cas.cat>
2021-08-04 20:27:08 +02:00

21 lines
545 B
Bash

#!/bin/sh -e
STATE="$(cat "${__object}/parameter/state")"
if [ "${STATE}" != "present" ]; then
exit
fi
ETC_DIR="/etc"
SERVICE_NAME="${__object_id}"
CONFIG_FILE_DEST="${ETC_DIR}/${SERVICE_NAME}.conf"
BIN_DIR="/usr/local/bin"
VERSION_FILE="${BIN_DIR}/.${SERVICE_NAME}.cdist.version"
# We only restart here if there was a config change
# but there was not a version change
if grep -qE "^__file${CONFIG_FILE_DEST}" "${__messages_in}" && \
grep -qvE "^__file${VERSION_FILE}" "${__messages_in}"; then
echo "service ${SERVICE_NAME} restart"
fi