#!/bin/bash set -e configure() { LOGDIR="/var/log/atop" # this has been in place since at least buster. remove post-trixie rm -f "${LOGDIR}/dummy_after" "${LOGDIR}/dummy_before" # check whether atop will read its own latest file # point atop to the latest file and check for output on stdout # the pipe will prevent atop from going interactive, and if it # won't read the file, stdout will be empty. LATESTFILE="$(find "${LOGDIR}" -maxdepth 1 -type f \ -regextype posix-egrep -regex '.*/atop_[0-9]+$' \ -printf '%p\n' | sort | tail -n 1)" if [ -n "${LATESTFILE}" ]; then if ! atop -r "${LATESTFILE}" 2>/dev/null | head -n 5 | grep -q '.'; then # updating from an older version which won't read # the old log file format # take a backup of the old file and convert it BACKUPFILE="${LATESTFILE}_oldformat" if [ -e "${BACKUPFILE}" ]; then TIMESTAMP=$(date +%Y%m%dT%H%M%S) BACKUPFILE="${LATESTFILE}_oldformat_${TIMESTAMP}" fi if mv "${LATESTFILE}" "${BACKUPFILE}"; then if atopconvert "${BACKUPFILE}" "${LATESTFILE}" >/dev/null; then if ! atop -r "${LATESTFILE}" 2>/dev/null | head -n 5 | grep -q '.'; then printf >&2 "atop postinst: error reading converted log file %s.\\n" "${LATESTFILE}" # remove generated file, we do without the converted file rm -f "${LATESTFILE}" fi else printf >&2 "atop postinst: conversion failed from %s to new atop raw file format %s" "${BACKUPFILE}" "${LATESTFILE}" # remove generated file, we do without the converted file rm -f "${LATESTFILE}" fi else printf >&2 "atop postinst: failed to back up %s\\n" "${LATESTFILE}" exit 1 fi fi fi } case "$1" in configure) configure ;; esac # Automatically added by dh_installdeb/13.27 dpkg-maintscript-helper rm_conffile /etc/logrotate.d/psaccs_atop -- "$@" dpkg-maintscript-helper rm_conffile /etc/logrotate.d/psaccu_atop -- "$@" # End automatically added section # Automatically added by dh_installinit/13.27 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "$DPKG_ROOT" ] && [ -x "/etc/init.d/atopacct" ]; then update-rc.d atopacct defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native atopacct $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installinit/13.27 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "$DPKG_ROOT" ] && [ -x "/etc/init.d/atop" ]; then update-rc.d atop defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native atop $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atop-rotate.timer' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'atop-rotate.timer'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'atop-rotate.timer' >/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 'atop-rotate.timer' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atop-rotate.timer' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atopacct.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'atopacct.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'atopacct.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 'atopacct.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atopacct.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atop.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'atop.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'atop.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 'atop.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.27 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 'atop.service' >/dev/null || true fi fi # End automatically added section # vim: tabstop=4 expandtab