~ubuntu-branches/ubuntu/precise/hinfo/precise

« back to all changes in this revision

Viewing changes to debian/postinst

  • Committer: Bazaar Package Importer
  • Author(s): Blars Blarson
  • Date: 2004-02-18 20:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20040218200127-xztif5sqn2keson5
Tags: 1.01-2
* Use bash for postinst to workaround dash limitation.  (closes: #233480)
* convert to po-debconf
* German debconf translation from Michael Ablassmeier
* spelling fixes from Michael Ablassmeier
* mention currently active DNSbl in description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/bash
 
2
# postinst script for hinfo
 
3
 
 
4
set -e
 
5
 
 
6
# workaround for debconf bug -- save stdin in fd 52 (restore after db_stop)
 
7
# if we arn't given the chance, try /dev/tty
 
8
if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
 
9
    exec 52<&0
 
10
    hinfo_redir=1
 
11
    export hinfo_redir
 
12
fi
 
13
 
 
14
. /usr/share/debconf/confmodule
 
15
 
 
16
case "$1" in
 
17
configure|reconfigure)
 
18
    where=
 
19
    for period in daily weekly monthly
 
20
    do
 
21
        if [ -x /etc/cron.${period}/hinfo ] ; then
 
22
            if [ -z "$where" ] ; then
 
23
                where=$period
 
24
            else
 
25
                if cmp /etc/cron.${period}/hinfo /etc/cron.${where}/hinfo
 
26
                then
 
27
                    rm /etc/cron/${where}/hinfo
 
28
                    where=$period
 
29
                else
 
30
                    echo "You have both /etc/cron.${where}/hinfo and /etc/cron.${period}/hinfo" 1>&2
 
31
                    echo "One of these should be remvoed" 1>&2
 
32
                fi
 
33
            fi
 
34
        fi
 
35
    done
 
36
    db_get hinfo/autoupdate
 
37
    au=$RET
 
38
    case "$au" in
 
39
never)
 
40
        db_stop
 
41
        if [ ! "$hinfo_redir" ] ; then
 
42
            exec 0</dev/tty
 
43
        else
 
44
            exec 0<&52
 
45
        fi
 
46
        if [ ! -z "$where" ] ; then
 
47
            ucf -s /usr/share/hinfo /dev/null /etc/cron.${where}/hinfo
 
48
            if [ -f /etc/cron.${where}/hinfo -a ! -s /etc/cron.${where}/hinfo ]
 
49
            then
 
50
                rm /etc/cron.${where}/hinfo
 
51
            fi
 
52
        fi
 
53
        ;;
 
54
now)
 
55
        db_stop
 
56
        if [ ! "$hinfo_redir" ] ; then
 
57
            exec 0</dev/tty
 
58
        else
 
59
            exec 0<&52
 
60
        fi
 
61
        if [ ! -z "$where" ] ; then
 
62
            ucf -s /usr/share/hinfo /dev/null /etc/cron.${where}/hinfo
 
63
            if [ -f /etc/cron.${where}/hinfo -a ! -s /etc/cron.${where}/hinfo ]
 
64
            then
 
65
                rm /etc/cron.${where}/hinfo
 
66
            fi
 
67
        fi
 
68
        /usr/sbin/hinfo-update || true
 
69
        ;;
 
70
daily|weekly|monthly)
 
71
        db_get hinfo/autoupdateverbose
 
72
        verb=$RET
 
73
        db_stop
 
74
        if [ ! "$hinfo_redir" ] ; then
 
75
            exec 0</dev/tty
 
76
        else
 
77
            exec 0<&52
 
78
        fi
 
79
        if id hinfo >/dev/null 2>&1 ; then : ; else
 
80
            adduser --system --disabled-login --home /var/lib/hinfo hinfo
 
81
        fi
 
82
        chown -R hinfo /var/lib/hinfo
 
83
        if [ ! -f /etc/cron.${au}/hinfo -a ! -z "$where" ] ; then
 
84
            mv /etc/cron.${where}/hinfo /etc/cron.${au}/hinfo
 
85
        fi
 
86
        temp=`tempfile -p hinfo -m 0755`
 
87
        cat <<EOF >$temp
 
88
#!/bin/sh
 
89
if [ -x /usr/sbin/hinfo-update ] ; then
 
90
    su hinfo -s /bin/sh -c '/usr/sbin/hinfo-update -$verb'
 
91
fi
 
92
EOF
 
93
        ucf -s /usr/share/hinfo $temp /etc/cron.${au}/hinfo
 
94
        chmod u+x /etc/cron.${au}/hinfo
 
95
        rm $temp
 
96
        su hinfo -s /bin/sh -c /usr/sbin/hinfo-update || true
 
97
        ;;
 
98
    esac
 
99
    ;;
 
100
 
 
101
abort-upgrade|abort-remove|abort-deconfigure)
 
102
 
 
103
    ;;
 
104
 
 
105
*)
 
106
        echo "postinst called with unknown argument \`$1'" >&2
 
107
        exit 1
 
108
    ;;
 
109
esac
 
110
 
 
111
# dh_installdeb will replace this with shell code automatically
 
112
# generated by other debhelper scripts.
 
113
 
 
114
#DEBHELPER#
 
115
 
 
116
exit 0
 
117
 
 
118