#! /bin/sh . /usr/share/debconf/confmodule pkg=nsca case "$1" in configure) db_get nsca/run-nsca-daemon && new_runnsca="$RET" ;; abort-upgrade|abort-remove|abort-deconfigure) exit 0 ;; *) echo "postinst called with unknown argument" exit 1 ;; esac # if nsca's init script is already configured, we must reflect # that as the source of configuration, not debconf itself. # this function figures that out. note this is slightly # different from the run_nsca in config, as state 105 is # treated differently at this point (since we know the files # are unpacked at this point) run_nsca(){ set +e invoke-rc.d --query nsca start 2>/dev/null invoke_said=$? set -e case $invoke_said in # 101 == disabled 101) echo "false" ;; # 104 == enabled 104) echo "true" ;; # 105 == we don't know 105) echo "unknown" ;; # anything else is "undefined", so we then use our defaults *) if which icinga >/dev/null 2>&1 || \ which icinga2 >/dev/null 2>&1 || \ which nagios3 >/dev/null 2>&1 || \ which nagios2 >/dev/null 2>&1 || \ which nagios >/dev/null 2>&1 ; then echo "true" else echo "false" fi ;; esac } # do this manually to allow the debconf setting to control it: # (don't worry, the debconf setting respects the local modifications) if [ -x "/etc/init.d/nsca" ]; then old_runnsca=`run_nsca` # if anything has changed... if [ "$new_runnsca" != "$old_runnsca" ]; then update-rc.d -f nsca remove >/dev/null 2>&1 if [ "$new_runnsca" = "false" ]; then update-rc.d nsca stop 16 2 3 4 5 . >/dev/null else update-rc.d nsca defaults >/dev/null fi fi if [ "$new_runnsca" = "false" ]; then exit 0 fi if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then invoke-rc.d nsca start else /etc/init.d/nsca start fi fi # always reset this question, to make sure we're not depending on it db_reset nsca/run-nsca-daemon db_stop # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "$(command -v systemd-tmpfiles)" ]; then systemd-tmpfiles ${DPKG_ROOT:+--root="$DPKG_ROOT"} --create nsca.conf || true fi fi # End automatically added section # Automatically added by dh_installinit/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/nsca" ]; then update-rc.d nsca defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native nsca $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'nsca.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'nsca.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'nsca.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'nsca.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'nsca.service' >/dev/null || true fi fi # End automatically added section