File: wtmpdb.postinst

package info (click to toggle)
wtmpdb 0.75.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 692 kB
  • sloc: ansic: 4,222; xml: 715; sh: 81; makefile: 16
file content (33 lines) | stat: -rw-r--r-- 863 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

set -e

if [ "$1" = "configure" ] && \
  dpkg --compare-versions "$2" ge "0.13.0-6~" && \
  dpkg --compare-versions "$2" lt "0.72.0-2~"
then
  echo "Forcibly resetting runlevels for wtmpdb-update-boot on this upgrade"
  update-rc.d -f wtmpdb-update-boot remove || true
fi

old_log="${DPKG_ROOT:-}/var/log/wtmp"
new_log="${DPKG_ROOT:-}/var/log/wtmp.db"
tmp_log="$new_log.import-tmp"

# If wtmp logs are present on first installation, import them.
if [ "$1" = "configure" ] && [ -z "$2" ] && \
  [ -s "$old_log" ] && [ ! -s "$new_log" ]
then
  # Convert all entries or none.
  printf "Converting wtmp login records into wtmpdb database ... "
  if wtmpdb import -f "$tmp_log" "$old_log"
  then
    [ ! -s "$tmp_log" ] || mv -f "$tmp_log" "$new_log"
    echo "done"
  else
    [ ! -s "$tmp_log" ] || rm -f "$tmp_log"
    echo "failed"
  fi
fi

#DEBHELPER#