/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.postinst

Tags: version-1.0.10-1
* Makefile (version): Changed to "1.0.10".
* NEWS (Version 1.0.10): New entry.
* debian/changelog (1.0.10-1): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash -e
 
1
#!/bin/sh -e
2
2
# This script can be called in the following ways:
3
3
#
4
4
# After the package was installed:
15
15
# If prerm fails during replacement due to conflict:
16
16
#       <postinst> abort-remove in-favour <new-package> <version>
17
17
 
18
 
. /usr/share/debconf/confmodule
19
 
 
20
18
# Update the initial RAM file system image
21
19
update_initramfs()
22
20
{
23
21
    if [ -x /usr/sbin/update-initramfs ]; then
24
22
        update-initramfs -u -k all
25
23
    fi
 
24
    
 
25
    if dpkg --compare-versions "$2" lt-nl "1.0.10-1"; then
 
26
        # Make old initrd.img files unreadable too, in case they were
 
27
        # created with mandos-client 1.0.8 or older.
 
28
        find /boot -maxdepth 1 -type f -name "initrd.img-*.bak" \
 
29
            -print0 | xargs --null --no-run-if-empty chmod o-r
 
30
    fi
26
31
}
27
32
 
28
33
# Add user and group
29
34
add_mandos_user(){
30
 
    if ! getent passwd mandos >/dev/null; then
31
 
        adduser --disabled-password  --quiet --system \
32
 
            --home /nonexistent --no-create-home \
33
 
            --gecos "Mandos password system" --group mandos
 
35
    # Rename old "mandos" user and group
 
36
    case "`getent passwd mandos`" in
 
37
        *:Mandos\ password\ system,,,:/nonexistent:/bin/false)
 
38
            usermod --login _mandos mandos
 
39
            groupmod --new-name _mandos mandos
 
40
            return
 
41
            ;;
 
42
    esac
 
43
    # Create new user and group
 
44
    if ! getent passwd _mandos >/dev/null; then
 
45
        adduser --system --force-badname --quiet --home /nonexistent \
 
46
            --no-create-home --group --disabled-password \
 
47
            --gecos "Mandos password system" _mandos
34
48
    fi
35
49
}
36
50
 
47
61
 
48
62
case "$1" in
49
63
    configure)
50
 
        add_mandos_user
51
 
        create_key
52
 
        update_initramfs
 
64
        add_mandos_user "$@"
 
65
        create_key "$@"
 
66
        update_initramfs "$@"
53
67
        ;;
54
68
    abort-upgrade|abort-deconfigure|abort-remove)
55
69
        ;;
56
70
 
57
71
    *)
58
 
        echo "$0 called with unknown argument \`$1'" 1>&2
 
72
        echo "$0 called with unknown argument '$1'" 1>&2
59
73
        exit 1
60
74
        ;;
61
75
esac