/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to debian/mandos-client.postrm

  • Committer: Teddy Hogeborn
  • Date: 2024-09-08 07:15:13 UTC
  • Revision ID: teddy@recompile.se-20240908071513-2jnx7ja8hlct42hl
Minor fix for manual Makefile uninstallations

If the Mandos systemd unit file was not installed, it was still
removed by the "purge-server" target.  If systemd is not installed,
this could mean removal of "mandos.service" from the root directory.

(Note: this was *not* used by the Debian package as a method of
uninstallation; this was only ever done by the Makefile if "make
purge-server" was called by hand.  And a "mandos.service" file was
presumably also unlikely to exist in the root directory.)

* Makefile (purge-server): Only remove systemd service file
  "mandos.service" if the same conditions exist which permitted its
  initial installation in the "install-server" target.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# This script can be called in the following ways:
 
3
#
 
4
# After the package was removed:
 
5
#       <postrm> remove
 
6
#
 
7
# After the package was purged:
 
8
#       <postrm> purge
 
9
#
 
10
# After the package was upgraded:
 
11
#       <old-postrm> upgrade <new-version>
 
12
# if that fails:
 
13
#       <new-postrm> failed-upgrade <old-version>
 
14
#
 
15
#
 
16
# After all of the packages files have been replaced:
 
17
#       <postrm> disappear <overwriting-package> <version>
 
18
#
 
19
#
 
20
# If preinst fails during install:
 
21
#       <new-postrm> abort-install
 
22
#
 
23
# If preinst fails during upgrade of removed package:
 
24
#       <new-postrm> abort-install <old-version>
 
25
#
 
26
# If preinst fails during upgrade:
 
27
#       <new-postrm> abort-upgrade <old-version>
 
28
 
 
29
set -e
 
30
 
 
31
# Update the initial RAM file system image
 
32
update_initramfs()
 
33
{
 
34
    if command -v update-initramfs >/dev/null; then
 
35
        update-initramfs -k all -u 1>&2
 
36
    elif command -v dracut >/dev/null; then
 
37
        # Logic taken from dracut.postinst
 
38
        for kernel in /boot/vmlinu[xz]-*; do
 
39
            kversion="${kernel#/boot/vmlinu[xz]-}"
 
40
            if [ "$kversion" != "*" ]; then
 
41
                /etc/kernel/postinst.d/dracut "$kversion" 1>&2
 
42
            fi
 
43
        done
 
44
    fi
 
45
}
 
46
 
 
47
case "$1" in
 
48
    remove)
 
49
        update_initramfs
 
50
        ;;
 
51
 
 
52
    purge)
 
53
        shred --remove /etc/keys/mandos/seckey.txt \
 
54
            /etc/keys/mandos/tls-privkey.pem 2>/dev/null || :
 
55
        rm --force /etc/mandos/plugin-runner.conf \
 
56
            /etc/keys/mandos/pubkey.txt \
 
57
            /etc/keys/mandos/seckey.txt \
 
58
            /etc/keys/mandos/tls-privkey.pem \
 
59
            /etc/keys/mandos/tls-pubkey.pem \
 
60
            /etc/keys/mandos/dhparams.pem 2>/dev/null
 
61
        update_initramfs
 
62
        ;;
 
63
    upgrade|failed-upgrade|disappear|abort-install|abort-upgrade)
 
64
        ;;
 
65
 
 
66
    *)
 
67
        echo "$0 called with unknown argument '$1'" 1>&2
 
68
        exit 1
 
69
        ;;
 
70
esac
 
71
 
 
72
#DEBHELPER#
 
73
 
 
74
exit 0