source: trunk/debathena/config/auto-update/debian/debathena-auto-update.postinst @ 25361

Revision 25361, 3.4 KB checked in by jdreed, 13 years ago (diff)
In auto-update: * Revert changes from 1.31 (which didn't actually work) and instead run all aptitude --download-only invocations inside timeout(1).
RevLine 
[24522]1#!/bin/sh
[24523]2# postinst script for debathena-auto-update
[24522]3#
4# see: dh_installdeb(1)
5
6set -e
7
8# summary of how this script can be called:
9#        * <postinst> `configure' <most-recently-configured-version>
10#        * <old-postinst> `abort-upgrade' <new version>
11#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12#          <new-version>
13#        * <postinst> `abort-remove'
14#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15#          <failed-install-package> <version> `removing'
16#          <conflicting-package> <version>
17# for details, see http://www.debian.org/doc/debian-policy/ or
18# the debian-policy package
19
[24935]20desync2cron() {
21    hour=$1
22    interval=$2
23    shift 2
24    desync=`desync -n $interval`
25    mins=`echo $desync % 60 | bc`
26    hours=`echo "$hour + ($desync / 60)" | bc`
27    if [ $hours -ge 24 ]; then
28        hours=`echo $hours - 24 | bc`
29    fi
30    echo "$mins $hours * * * $*"
31}
[24522]32
[24935]33UPD_CRONFILE=/etc/cron.d/athena-auto-update
34UPG_CRONFILE=/etc/cron.d/athena-auto-upgrade
35
[24992]36# We stopped shipping our own cron.d file in 1.21, so remove it
37# dpkg-maintscript-helper exists in maverick+
38if dpkg-maintscript-helper supports rm_conffile 2> /dev/null; then
39    dpkg-maintscript-helper rm_conffile \
[25005]40        /etc/cron.d/debathena-auto-update 1.22.2 -- "$@"
[24992]41else
42    # From http://wiki.debian.org/DpkgConffileHandling
[25004]43    # Which is full of lies, like the fact that postinsts get
44    # called with "install" or "upgrade" when they totally don't
[24992]45    rm_conffile() {
46        local PKGNAME="$1" # Unused
47        local CONFFILE="$2"
48        if [ -f "$CONFFILE".dpkg-del ]; then
49            rm -f "$CONFFILE".dpkg-del
50        fi
51    }
52    case "$1" in
[25004]53        configure)
[25005]54            if dpkg --compare-versions "$2" le-nl 1.22.2; then
[24992]55                rm_conffile debathena-auto-update "/etc/cron.d/debathena-auto-update"
56            fi
57    esac
58fi
59
[24522]60case "$1" in
61    configure)
62        # Nuke /var/lib/athena-update-status on 1.18,
63        # since we changed its format. It will be created
64        # at the next auto update
65        if dpkg --compare-versions "$2" lt 1.18~ &&
66            [ -f /var/lib/athena-update-status ]; then
67            rm /var/lib/athena-update-status
68        fi
[24988]69       
[24942]70        if [ ! -f /var/lib/athena-update-status ]; then
71            echo "$(date +"%s")|$(date +"%s")|ok|Package configured" > /var/lib/athena-update-status
72        fi
73
[24935]74        rm -f $UPD_CRONFILE
75        rm -f $UPG_CRONFILE
76
77        echo "# Automatically generated by debathena-auto-update postinst" > $UPD_CRONFILE
[25068]78        echo "SHELL=/bin/sh" >> $UPD_CRONFILE
79        echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> $UPD_CRONFILE
[25067]80
[24935]81        for h in 2 4 6; do
82            desync2cron $h 120 root /usr/sbin/athena-auto-update cron >> $UPD_CRONFILE
83        done
84        for h in 8 14 20; do
85            desync2cron $h 360 root /usr/sbin/athena-auto-update cron >> $UPD_CRONFILE
86        done
87        echo "# Automatically generated by debathena-auto-update postinst" > $UPG_CRONFILE
[25068]88        echo "SHELL=/bin/sh" >> $UPG_CRONFILE
89        echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> $UPG_CRONFILE
[24935]90
91        upginterval=360
92        hostname=`hostname | tr 'A-Z' 'a-z'`
93        case $hostname in
94            m38-370*)
[24936]95                upginterval=480
[24935]96                ;;
97            w20-575*)
[24936]98                upginterval=420
[24935]99                ;;
100        esac
[25020]101        for h in 1 2 3; do
102            desync2cron $h $upginterval root /usr/sbin/athena-auto-upgrade >> $UPG_CRONFILE
103        done
[24522]104       
105    ;;
106
107    abort-upgrade|abort-remove|abort-deconfigure)
108    ;;
109
110    *)
111        echo "postinst called with unknown argument \`$1'" >&2
112        exit 1
113    ;;
114esac
115
116# dh_installdeb will replace this with shell code automatically
117# generated by other debhelper scripts.
118
119#DEBHELPER#
120
121exit 0
Note: See TracBrowser for help on using the repository browser.