#!/bin/bash

set -e

restart() {
  if [ -d /run/systemd ]; then
    /bin/systemctl daemon-reload
    /bin/systemctl restart yandex-sysconf
    /bin/systemctl restart yandex-sysconf.timer
    /bin/systemctl enable yandex-sysconf
    /bin/systemctl enable yandex-sysconf.timer
  fi
}

case "$1" in
	configure)
		# workaround for race in cron daemon
		/bin/touch --time=m /etc/cron.d

    if [ -z $HOSTMAN ]; then
      restart
    fi
	;;
    abort-upgrade|abort-remove|abort-deconfigure)
	;;
	*)
		echo "postinst called with unknown argument \`$1'" >&2
		exit 1
	;;
esac

exit 0
