Remove obsolete config file diversions
[grml-etc.git] / debian / postrm
1 #!/bin/sh
2 # Filename:      postrm
3 # Purpose:       postrm script for package grml-etc
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 set -e
10
11 TO_UNDIVERT1="ssh"
12
13 undivert_gen() {
14     DEXT=${3:-original}
15     dpkg-divert --remove --rename --package grml-etc \
16         --divert $2/$1.$DEXT $2/$1 #> /dev/null
17 }
18
19 replace_grml_with_orig_inittab() {
20   if grep -q '^l0:0:wait:/etc/init.d/grml-halt$' /etc/inittab ; then
21      sed -i 's|^l0:0:wait:/etc/init.d/grml-halt|l0:0:wait:/etc/init.d/rc 0|' /etc/inittab
22   fi
23
24   if grep -q '^l6:6:wait:/etc/init.d/grml-reboot$' /etc/inittab ; then
25      sed -i 's|^l6:6:wait:/etc/init.d/grml-reboot|l6:6:wait:/etc/init.d/rc 6|' /etc/inittab
26   fi
27 }
28
29 case "$1" in
30     purge)
31         for cmd in $TO_UNDIVERT1; do
32                 undivert_gen $cmd /etc/init.d
33         done
34
35         # make sure the ssh init script even exists if something is failing...
36         if ls /etc/init.d/ssh* 1>/dev/null 2>&1 ; then
37           if [ ! -f /etc/init.d/ssh -a /etc/init.d/ssh.original.dpkg-new ] ; then
38              mv /etc/init.d/ssh.original.dpkg-new /etc/init.d/ssh
39           fi
40         fi
41
42         replace_grml_with_orig_inittab
43      ;;
44
45    remove|abort-install|disappear)
46         replace_grml_with_orig_inittab
47      ;;
48
49    upgrade|failed-upgrade|abort-install|abort-upgrade)
50      ;;
51
52     *)
53       echo "postrm called with unknown argument $1" >&2
54       exit 1
55 esac
56
57 #DEBHELPER#
58
59 exit 0
60
61 ## END OF FILE #################################################################