| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
if [ "$1" = "configure" ] && \ |
| 6 |
dpkg --compare-versions "$2" ge "0.13.0-6~" && \ |
| 7 |
dpkg --compare-versions "$2" lt "0.72.0-2~" |
| 8 |
then |
| 9 |
echo "Forcibly resetting runlevels for wtmpdb-update-boot on this upgrade" |
| 10 |
update-rc.d -f wtmpdb-update-boot remove || true |
| 11 |
fi |
| 12 |
|
| 13 |
# Remove dangling systemd timer symlink from 0.73.0-2 and earlier |
| 14 |
f="${DPKG_ROOT:-}/etc/systemd/system/timers.target.wants/wtmpdb-rotate.timer" |
| 15 |
if [ -h "$f" ] && [ ! -e "$f" ] |
| 16 |
then |
| 17 |
rm -f "$f" |
| 18 |
fi |
| 19 |
|
| 20 |
old_log="${DPKG_ROOT:-}/var/log/wtmp" |
| 21 |
new_log="${DPKG_ROOT:-}/var/log/wtmp.db" |
| 22 |
tmp_log="$new_log.import-tmp" |
| 23 |
|
| 24 |
# If wtmp logs are present on first installation, import them. |
| 25 |
if [ "$1" = "configure" ] && [ -z "$2" ] && \ |
| 26 |
[ -s "$old_log" ] && [ ! -s "$new_log" ] |
| 27 |
then |
| 28 |
# Convert all entries or none. |
| 29 |
printf "Converting wtmp login records into wtmpdb database ... " |
| 30 |
if wtmpdb import -f "$tmp_log" "$old_log" |
| 31 |
then |
| 32 |
[ ! -s "$tmp_log" ] || mv -f "$tmp_log" "$new_log" |
| 33 |
echo "done" |
| 34 |
else |
| 35 |
[ ! -s "$tmp_log" ] || rm -f "$tmp_log" |
| 36 |
echo "failed" |
| 37 |
fi |
| 38 |
fi |
| 39 |
|
| 40 |
#DEBHELPER# |