#!/bin/sh set -e . /usr/share/debconf/confmodule OLD_CONF="/etc/default/ntopng.dpkg-backup" CONF="/etc/ntopng.conf" OLD_DATA_DIR="/var/tmp/ntopng" DATA_DIR="/var/lib/ntopng" if [ "$1" = configure ]; then if [ -f $OLD_CONF ]; then # Migrate settings (except ADD_ARGS) from /etc/default/ntopng to # /etc/ntopng.conf . $OLD_CONF || true if [ -n "$HTTP_PORT" ]; then sed -i -e "s/^-w=.*\$/-w=$HTTP_PORT/" $CONF fi if [ -n "$INTERFACES" ]; then # Make sure the file ends with a newline. echo >> $CONF for i in $INTERFACES; do echo "-i=$i" >> $CONF done fi fi adduser --quiet --system --group --home $DATA_DIR --no-create-home ntopng chown ntopng:ntopng $DATA_DIR chmod 700 $DATA_DIR # Migrate data according to # https://www.ntop.org/support/faq/migrate-the-data-directory-in-ntopng/ # in a safe way (i.e. no recursive chmod/chown, to ensure we only migrate # files readable by the user nobody, and the new files are written as # the ntopng user with permissions). if [ -d $OLD_DATA_DIR ]; then echo Migrating data from $OLD_DATA_DIR to $DATA_DIR... runuser -u nobody -- tar cf - -C $OLD_DATA_DIR . \ | ( umask 077; runuser -u ntopng -- tar xf - -C $DATA_DIR ) mv $OLD_DATA_DIR "$OLD_DATA_DIR.dpkg-old.$(date --iso-8601=seconds)" fi # Fix permissions of /var/log/ntopng. Older version may have left a # world-writable log file. chown root:ntopng /var/log/ntopng chmod 770 /var/log/ntopng chown -fR ntopng:ntopng /var/log/ntopng/* || true chmod -fR 600 /var/log/ntopng/* || true fi # Automatically added by dh_installinit/13.15.3 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/ntopng" ]; then update-rc.d ntopng defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native ntopng $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.15.3 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 'ntopng.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'ntopng.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'ntopng.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 'ntopng.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.15.3 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 'ntopng.service' >/dev/null || true fi fi # End automatically added section