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

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
#! /bin/bash
# postinst script for hinfo

set -e

# workaround for debconf bug -- save stdin in fd 52 (restore after db_stop)
# if we arn't given the chance, try /dev/tty
if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
    exec 52<&0
    hinfo_redir=1
    export hinfo_redir
fi

. /usr/share/debconf/confmodule

case "$1" in
configure|reconfigure)
    where=
    for period in daily weekly monthly
    do
	if [ -x /etc/cron.${period}/hinfo ] ; then
	    if [ -z "$where" ] ; then
	        where=$period
	    else
	        if cmp /etc/cron.${period}/hinfo /etc/cron.${where}/hinfo
		then
		    rm /etc/cron/${where}/hinfo
		    where=$period
		else
		    echo "You have both /etc/cron.${where}/hinfo and /etc/cron.${period}/hinfo" 1>&2
		    echo "One of these should be remvoed" 1>&2
		fi
	    fi
	fi
    done
    db_get hinfo/autoupdate
    au=$RET
    case "$au" in
never)
	db_stop
	if [ ! "$hinfo_redir" ] ; then
	    exec 0</dev/tty
	else
	    exec 0<&52
	fi
	if [ ! -z "$where" ] ; then
	    ucf -s /usr/share/hinfo /dev/null /etc/cron.${where}/hinfo
	    if [ -f /etc/cron.${where}/hinfo -a ! -s /etc/cron.${where}/hinfo ]
	    then
	        rm /etc/cron.${where}/hinfo
	    fi
	fi
	;;
now)
	db_stop
	if [ ! "$hinfo_redir" ] ; then
	    exec 0</dev/tty
	else
	    exec 0<&52
	fi
	if [ ! -z "$where" ] ; then
	    ucf -s /usr/share/hinfo /dev/null /etc/cron.${where}/hinfo
	    if [ -f /etc/cron.${where}/hinfo -a ! -s /etc/cron.${where}/hinfo ]
	    then
	        rm /etc/cron.${where}/hinfo
	    fi
	fi
	/usr/sbin/hinfo-update || true
	;;
daily|weekly|monthly)
        db_get hinfo/autoupdateverbose
	verb=$RET
	db_stop
	if [ ! "$hinfo_redir" ] ; then
	    exec 0</dev/tty
	else
	    exec 0<&52
	fi
	if id hinfo >/dev/null 2>&1 ; then : ; else
	    adduser --system --disabled-login --home /var/lib/hinfo hinfo
	fi
	chown -R hinfo /var/lib/hinfo
	if [ ! -f /etc/cron.${au}/hinfo -a ! -z "$where" ] ; then
	    mv /etc/cron.${where}/hinfo /etc/cron.${au}/hinfo
	fi
	temp=`tempfile -p hinfo -m 0755`
	cat <<EOF >$temp
#!/bin/sh
if [ -x /usr/sbin/hinfo-update ] ; then
    su hinfo -s /bin/sh -c '/usr/sbin/hinfo-update -$verb'
fi
EOF
	ucf -s /usr/share/hinfo $temp /etc/cron.${au}/hinfo
	chmod u+x /etc/cron.${au}/hinfo
	rm $temp
	su hinfo -s /bin/sh -c /usr/sbin/hinfo-update || true
	;;
    esac
    ;;

abort-upgrade|abort-remove|abort-deconfigure)

    ;;

*)
        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