File: postinst

package info (click to toggle)
systraq 20201231-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 2,172 kB
  • sloc: sh: 821; makefile: 130
file content (106 lines) | stat: -rw-r--r-- 3,042 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
#! /bin/sh -e

# postinst script for systraq

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

SYSTRAQUSER=debian-systraq

# etch ships       0.0.20050213-8
# lennie           0.0.20081217-1 (?)
# squeeze          0.0.20081217-1+squeeze2.1
# wheezy           0.0.20081217-3
# jessie

MD5VERSION=0.0.20070301-4 # last version using md5sum by default

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

    # be sure to succeed, even in case /var/lib/systraq does not exist.
    # if user does: install; purge (rm homedir, useraccount kept); install,
    # homedir will not exist now. see #730407
    mkdir -p /var/lib/systraq/filetraq || true
    chown $SYSTRAQUSER:$SYSTRAQUSER /var/lib/systraq \
        /var/lib/systraq/filetraq

    if ! test -f /var/lib/systraq/.forward
    then
        echo root >/var/lib/systraq/.forward
        chown $SYSTRAQUSER:$SYSTRAQUSER /var/lib/systraq/.forward
    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.  The
debian-systraq group will now be created.  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/libexec/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/libexec/systraq/$l /etc/systraq/systraq.d/$l
            fi
        else
            ln -s /usr/libexec/systraq/$l /etc/systraq/systraq.d/$l
        fi
    done

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

    # make sure debian-systraq can write to these files
    for f in /etc/systraq/filetraq.main.conf /etc/systraq/filetraq.conf
    do
        if ! test -f $f
        then
            touch $f; chown $SYSTRAQUSER $f
        fi
    done

    ;;

  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