File: postinst

package info (click to toggle)
systraq 0.0.20081217-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,424 kB
  • sloc: sh: 828; makefile: 122
file content (127 lines) | stat: -rw-r--r-- 3,760 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#! /bin/sh -e
# postinst script for systraq

# http://women.debian.org/wiki/English/MaintainerScripts

SYSTRAQUSER=debian-systraq
OLDSYSTRAQUSER=systraq
OLDVERSION=0.0.20050213-4 # etch ships 0.0.20050213-8
MD5VERSION=0.0.20070301-4 # last version using md5sum by default
USERMISSING=0

case "$1" in
  configure)
    if ! getent passwd $SYSTRAQUSER > /dev/null 2>&1
    then
        adduser --system --disabled-password --home /var/lib/systraq \
          --quiet --group $SYSTRAQUSER
        USERMISSING=1
    fi

    if getent passwd $OLDSYSTRAQUSER > /dev/null 2>&1 && [ $USERMISSING = 1 ]
    then
        if test -n "$2"
        then
            if dpkg --compare-versions "$2" le-nl $OLDVERSION
            then
                # we are upgraded from a package version where the systraq user
                # is called `systraq'.
                chown -R $SYSTRAQUSER:$SYSTRAQUSER /var/lib/systraq
                cat <<EOT
The new systraq username in the Debian package is now debian-systraq. The 
old systraq user may be safely removed after the package is configured.
EOT

            else
                cat <<EOT
You have a systraq user that was not installed by the systraq debian package.
I will not reuse this user. You might want to hand all files owned by the
systraq user over to debian-systraq; e.g. by running
    chown -R debian-systraq /var/lib/systraq
after this package is installed.
EOT
                cat <<EOT
Make sure you have a /etc/cron.d/systraq file from systraq >> $OLDVERSION.
EOT
            fi
        fi
    fi

    test -f /var/lib/systraq/.forward || echo root > /var/lib/systraq/.forward
    chown -R $SYSTRAQUSER:$SYSTRAQUSER /var/lib/systraq/.forward

    if ! test -d /var/lib/systraq/filetraq
    then
        mkdir /var/lib/systraq/filetraq
        chown $SYSTRAQUSER:$SYSTRAQUSER /var/lib/systraq/filetraq
    fi

    if ! getent group $SYSTRAQUSER > /dev/null 2>&1
    then
        cat <<EOT
You do have a debian-systraq user, but not a debian-systraq group
on your system. Your systraq user was not created by the systraq Debian package.
Please make sure your systraq user is a member of the debian-systraq group.
You can make this adjustment after this package is installed.
EOT
        addgroup --system --quiet $SYSTRAQUSER
    fi

    # deal with symlinks in /etc/systraq/systraq.d/
    LINKS=`ls /usr/share/systraq`

    # user can add links (or scripts), named AA-local
    # user can disable our links, by relinking to /bin/true
    #
    # initial install: create all our links
    # upgrade: 
    # fix broken links
    # see 10.7. Configuration files in debian-policy/policy.txt.gz

    for l in $LINKS
    do
        if test -L /etc/systraq/systraq.d/$l
        then
            if test ! -e /etc/systraq/systraq.d/$l
            then
                # broken symlink, fix it
                rm /etc/systraq/systraq.d/$l
                ln -s /usr/share/systraq/$l /etc/systraq/systraq.d/$l
            fi
        else
            ln -s /usr/share/systraq/$l /etc/systraq/systraq.d/$l
        fi
    done

    # Is systraq configured ?
    if ! test -f /etc/systraq/snapshot_pub.list
    then
        cp /usr/share/doc/systraq/examples/systraq_is_unconfigured /etc/systraq/
    fi

    if test -n "$2"
    then
        if dpkg --compare-versions "$2" le-nl $MD5VERSION
        then
            cp /usr/share/doc/systraq/examples/systraq_is_not_upgraded /etc/systraq/
        fi
    fi
    ;;

  failed-upgrade|abort-upgrade|abort-remove|abort-deconfigure|in-favour|removing)
    ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0