File: postinst

package info (click to toggle)
apt-cacher 1.7.32
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 552 kB
  • sloc: perl: 4,539; sh: 162; makefile: 5
file content (102 lines) | stat: -rwxr-xr-x 2,933 bytes parent folder | download | duplicates (5)
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
#! /bin/sh
# postinst script for apt-cacher
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.


# Source debconf library.
. /usr/share/debconf/confmodule

case "$1" in
    configure|reconfigure)

	# Handle upgrade from checksumming.conf

	CONFDIR=/etc/apt-cacher
	CONFFILE=$CONFDIR/apt-cacher.conf

	if [ -f $CONFDIR/checksumming.conf ]; then
	    if grep -E -q "^[[:space:]]*require.+apt-cacher-lib-cs.pl" $CONFDIR/checksumming.conf; then

		echo "Importing checksum config from $CONFDIR/checksumming.conf"

		if  grep -E -q "^[#[:space:]]*checksum=" $CONFFILE ; then
		    TEMP_FILE=$(mktemp -p /tmp)
		    sed 's/^[#[:space:]]*checksum=.*$/checksum=1/' $CONFFILE > "$TEMP_FILE"
		    mv "$TEMP_FILE" $CONFFILE
		    chmod 0644 $CONFFILE
		else
		    echo "checksum=1" >> $CONFFILE
		fi
	    fi
	    echo "Deleting obsolete file $CONFDIR/checksumming.conf"
	    rm $CONFDIR/checksumming.conf
	fi
	
	echo "Running apt-cacher's install script..."
	/usr/share/apt-cacher/install.pl

	db_get apt-cacher/mode
	case "$RET" in
	    daemon)
		echo "Setup apt-cacher running as standalone daemon."
		update-inetd --remove "3142\s.+/usr/sbin/apt-cacher" # PCRE
		;;
	    inetd)
		echo "Setup apt-cacher running from /etc/inetd.conf."
		update-inetd --add "3142\tstream\ttcp\tnowait\twww-data\t/usr/sbin/apt-cacher\tapt-cacher\t-i"
		;;
	    manual)
		# Do nothing, sysadmin is on their own
		cat <<EOF
Manual configuration of apt-cacher. Existing configuration left uncahnged.

If you are operating legacy CGI mode, this is deprecated and you really should
consider changing to one of the daemon modes. See cgi_advise_to_use and
cgi_redirect in man apt-cacher(8) for help in redirecting your clients.

To change your choice, run 

  dpkg-reconfigure apt-cacher

EOF
		;;
	esac
	db_stop
	;;

    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