| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# post-installation script for AIDE |
| 4 |
# A whole lot of this is "borrowed" from tripwire's postinst |
| 5 |
# |
| 6 |
|
| 7 |
set -e |
| 8 |
|
| 9 |
# We need debconf. |
| 10 |
. /usr/share/debconf/confmodule |
| 11 |
|
| 12 |
if [ -n "$AIDEDEBUG" ]; then |
| 13 |
printf "now debugging %s %s\n" "$0" "$@" |
| 14 |
set -x |
| 15 |
fi |
| 16 |
|
| 17 |
PKGNAME="aide" |
| 18 |
|
| 19 |
# Flags to be passed to aideinit |
| 20 |
aideinitflags="-b" |
| 21 |
|
| 22 |
# Make sure we should be running... |
| 23 |
case "$1" in |
| 24 |
configure) |
| 25 |
# continue below |
| 26 |
;; |
| 27 |
abort-upgrade|abort-remove|abort-deconfigure) |
| 28 |
exit 0 |
| 29 |
;; |
| 30 |
*) |
| 31 |
printf >&2 "postinst called with unknown argument %s\n" "$1" |
| 32 |
exit 0 |
| 33 |
;; |
| 34 |
esac |
| 35 |
|
| 36 |
# handle ucf-conffiles |
| 37 |
|
| 38 |
# ucf-helper-functions is part of ucf starting with bullseye |
| 39 |
# we keep our own (identical) version for the time being to be |
| 40 |
# backportable to buster. |
| 41 |
. /usr/share/aide/ucf-helper-functions.sh |
| 42 |
SRCDIR="/usr/share/$PKGNAME/config" |
| 43 |
TRGDIR="/etc" |
| 44 |
|
| 45 |
# added updating to 0.18-1 |
| 46 |
rm -rf /var/tmp/aide.cron.daily /var/tmp/aide.cron.daily.old.* |
| 47 |
|
| 48 |
rm -f /var/lib/aide/aide.conf.autogenerated |
| 49 |
if dpkg --compare-versions "$2" le "0.16-1"; then |
| 50 |
# we're updating from a version earlier than 0.16-1, rename DHCP conffiles |
| 51 |
rename_ucf_file /etc/aide/aide.conf.d/31_aide_dhcp3-client /etc/aide/aide.conf.d/31_aide_isc-dhcp-client |
| 52 |
rename_ucf_file /etc/aide/aide.conf.d/31_aide_dhcp3-server /etc/aide/aide.conf.d/31_aide_isc-dhcp-server |
| 53 |
fi |
| 54 |
handle_all_ucf_files $SRCDIR $TRGDIR |
| 55 |
|
| 56 |
# in aide 0.17.2-1, the smokeping snippet has been made static |
| 57 |
# instead of being a executable snippet. Remove x bits on an unchanged |
| 58 |
# file |
| 59 |
if [ "$(sha256sum /etc/aide/aide.conf.d/31_aide_smokeping)" = "99f11d04cf33318cef28cb71c252ee0f7b5c37e91893e813973ee120f301a5a7 /etc/aide/aide.conf.d/31_aide_smokeping" ]; then |
| 60 |
chmod 0644 /etc/aide/aide.conf.d/31_aide_smokeping |
| 61 |
fi |
| 62 |
if [ "$(sha256sum /etc/aide/aide.conf.d/31_aide_sudo)" = "9081189536ce23888827e6cd1f94884033fc5acb689bdf4083001e1ecd7a7e5a /etc/aide/aide.conf.d/31_aide_sudo" ]; then |
| 63 |
chmod 0644 /etc/aide/aide.conf.d/31_aide_sudo |
| 64 |
fi |
| 65 |
|
| 66 |
db_get aide/aideinit |
| 67 |
if [ "$RET" = "true" ]; then |
| 68 |
if [ -f "/var/lib/aide/aide.db.new" ]; then |
| 69 |
db_get aideinit/overwritenew |
| 70 |
if [ "$RET" = "true" ]; then |
| 71 |
aideinitflags="$aideinitflags -y" |
| 72 |
fi |
| 73 |
fi |
| 74 |
db_get aideinit/copynew |
| 75 |
if [ "$RET" = "true" ]; then |
| 76 |
aideinitflags="$aideinitflags -f" |
| 77 |
fi |
| 78 |
# borrowed this trick from man-db |
| 79 |
# just making sure it actually ends up in the background... |
| 80 |
start-stop-daemon --start --background --pidfile /dev/null \ |
| 81 |
--startas /usr/sbin/aideinit -- $aideinitflags |
| 82 |
db_set aide/aideinit false |
| 83 |
fi |
| 84 |
|
| 85 |
#DEBHELPER# |
| 86 |
|
| 87 |
# this needs to be after debhelper, otherwise the account doesn't |
| 88 |
# yet exist. |
| 89 |
if dpkg --compare-versions "$2" lt 0.17.5-1; then |
| 90 |
# we're updating from a version earlier than 0.17.5, chown logs |
| 91 |
# and databases |
| 92 |
chown --quiet _aide:adm /var/log/aide /var/log/aide/aide.log /var/log/aide/aide.log.* || true |
| 93 |
chmod --quiet 2755 /var/log/aide || true |
| 94 |
chown --quiet _aide:root /var/lib/aide/aide.db /var/lib/aide/aide.db.new || true |
| 95 |
fi |
| 96 |
if dpkg --compare-versions "$2" le 0.18.3-1; then |
| 97 |
# we're updating from 0.18.3-1 or earlier, chown aideinit logs |
| 98 |
chown --quiet _aide:adm /var/log/aide/aideinit.log /var/log/aide/aideinit.errors|| true |
| 99 |
fi |
| 100 |
|
| 101 |
exit 0 |
| 102 |
|
| 103 |
# vim:sw=4:sts=4:et: |
| 104 |
|