From bb703e2964ccf9131a5c5dea277a4c4b539256bc Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Wed, 23 Oct 2019 20:42:11 +0200 Subject: [PATCH] Fixed post-install logic for Debian --- build/linux/DEBIAN/hc-linux/postinst | 42 ++++++++++++++--------- build/linux/DEBIAN/hc-notify-eif/postinst | 19 ++++++---- build/linux/DEBIAN/hc-notify-sms/postinst | 19 ++++++---- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/build/linux/DEBIAN/hc-linux/postinst b/build/linux/DEBIAN/hc-linux/postinst index 2419d98..d7f56bc 100755 --- a/build/linux/DEBIAN/hc-linux/postinst +++ b/build/linux/DEBIAN/hc-linux/postinst @@ -16,25 +16,35 @@ chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null chown root:root /etc/logrotate.d/check_health 2>/dev/null chmod 644 /etc/logrotate.d/check_health 2>/dev/null # copy configuration files -if [[ ! -f ${HC_ETC_DIR}/core/check_health.conf ]] +if [[ -f ${HC_ETC_DIR}/core/check_health.conf.dist ]] then - # copy main configuration file - cp -p ${HC_ETC_DIR}/core/check_health.conf.dist ${HC_ETC_DIR}/core/check_health.conf >/dev/null - (( $? == 0 )) || \ - { - echo "ERROR: could not copy main config file in ${HC_ETC_DIR}/core" - exit 1 - } + if [[ ! -f ${HC_ETC_DIR}/core/check_health.conf ]] + then + # copy main configuration file + cp -p ${HC_ETC_DIR}/core/check_health.conf.dist ${HC_ETC_DIR}/core/check_health.conf >/dev/null + (( $? == 0 )) || \ + { + echo "ERROR: could not copy main config file in ${HC_ETC_DIR}/core" + exit 1 + } + fi +else + echo "WARN: could not check_health config .dist file in ${HC_ETC_DIR}/core" fi -if [[ ! -f ${HC_ETC_DIR}/check_host.conf ]] +if [[ -f ${HC_ETC_DIR}/check_host.conf.dist ]] then - # copy host check configuration file - cp -p ${HC_ETC_DIR}/check_host.conf.dist ${HC_ETC_DIR}/check_host.conf >/dev/null - (( $? == 0 )) || \ - { - echo "ERROR: could not copy host check config file in ${HC_ETC_DIR}" - exit 1 - } + if [[ ! -f ${HC_ETC_DIR}/check_host.conf ]] + then + # copy host check configuration file + cp -p ${HC_ETC_DIR}/check_host.conf.dist ${HC_ETC_DIR}/check_host.conf >/dev/null + (( $? == 0 )) || \ + { + echo "ERROR: could not copy host check config file in ${HC_ETC_DIR}" + exit 1 + } + fi +else + echo "WARN: could not find check_host config .dist file in ${HC_ETC_DIR}" fi # refresh symbolic FPATH links for core includes & plugins if [[ -x ${HC_BIN} ]] diff --git a/build/linux/DEBIAN/hc-notify-eif/postinst b/build/linux/DEBIAN/hc-notify-eif/postinst index 48a8319..9dfa0d1 100755 --- a/build/linux/DEBIAN/hc-notify-eif/postinst +++ b/build/linux/DEBIAN/hc-notify-eif/postinst @@ -10,14 +10,19 @@ echo "INFO: starting post-install script ..." # debian: reset ownerships chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null # copy plugin configuration file -if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_eif.conf ]] +if [[ -f ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ]] then - cp -p ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ${HC_ETC_DIR}/core/providers/notify_eif.conf >/dev/null - (( $? == 0 )) || \ - { - echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers" - exit 1 - } + if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_eif.conf ]] + then + cp -p ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ${HC_ETC_DIR}/core/providers/notify_eif.conf >/dev/null + (( $? == 0 )) || \ + { + echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers" + exit 1 + } + fi +else + echo "WARN: could not find plugin config .dist file in ${HC_ETC_DIR}/core/providers" fi # refresh symbolic FPATH links if [[ -x ${HC_BIN} ]] diff --git a/build/linux/DEBIAN/hc-notify-sms/postinst b/build/linux/DEBIAN/hc-notify-sms/postinst index 4c1ca26..5d64c00 100755 --- a/build/linux/DEBIAN/hc-notify-sms/postinst +++ b/build/linux/DEBIAN/hc-notify-sms/postinst @@ -10,14 +10,19 @@ echo "INFO: starting post-install script ..." # debian: reset ownerships chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null # copy plugin configuration file -if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_sms.conf ]] +if [[ -f ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ]] then - cp -p ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ${HC_ETC_DIR}/core/providers/notify_sms.conf >/dev/null - (( $? == 0 )) || \ - { - echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers" - exit 1 - } + if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_sms.conf ]] + then + cp -p ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ${HC_ETC_DIR}/core/providers/notify_sms.conf >/dev/null + (( $? == 0 )) || \ + { + echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers" + exit 1 + } + fi +else + echo "WARN: could not find plugin config .dist file in ${HC_ETC_DIR}/core/providers" fi # refresh symbolic FPATH links if [[ -x ${HC_BIN} ]]