Allow to limit the number of of client connections.
[privoxy.git] / debian / postinst
1 #! /bin/sh
2 # postinst script for privoxy
3 #
4 # see: dh_installdeb(1)
5
6 set -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 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 #          <failed-install-package> <version> `removing'
15 #          <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
18 #
19 # quoting from the policy:
20 #     Any necessary prompting should almost always be confined to the
21 #     post-installation script, and should be protected with a conditional
22 #     so that unnecessary prompting doesn't happen if a package's
23 #     installation fails and the `postinst' is called with `abort-upgrade',
24 #     `abort-remove' or `abort-deconfigure'.
25
26 CONFDIR=/etc/privoxy
27 CONFIG=$CONFDIR/config
28
29 case "$1" in
30     configure)
31         adduser --quiet --system --home $CONFDIR --no-create-home \
32             --ingroup nogroup --disabled-password privoxy
33         chown -R privoxy:adm /var/log/privoxy
34         chmod 750 /var/log/privoxy
35         chown privoxy $CONFDIR/user.action $CONFDIR/trust
36         [ -f $CONFDIR/matcha-all.action ] \
37             && chown privoxy $CONFDIR/match-all.action
38
39         if [ "x$2" != "x" ] && dpkg --compare-versions "$2" lt "3.0.4"
40         then
41             # Upgrading from a 3.0.3* version
42             chown root $CONFDIR/default.action
43         fi
44
45         if [ "x$2" != "x" ] && dpkg --compare-versions "$2" lt "3.0.7" \
46             && grep -q '^actionsfile [a-z]*[[:space:]]*#.*$' $CONFIG
47         then
48             # Upgrading from version before 3.0.7 where the user kept his old 
49             # (modified) config file:
50             # Try to change   "actionsfile foo"  to  "actionsfile foo.action"
51             # as needed in 3.0.7:
52             sed 's/^actionsfile \([a-z]*\)\([   ]*\#\)/actionsfile \1.action\2/' \
53                 -i.bak $CONFIG
54         fi
55
56         if [ "x$2" != "x" ] && dpkg --compare-versions "$2" lt "3.0.11"
57         then
58             # Upgrading from a version before 3.0.11
59             # Try to work around problems with missing action files
60             if grep -q '^actionsfile.*global.action' $CONFIG
61             then
62                 if [ -e $CONFDIR/global.action ]
63                 then
64                     mv $CONFDIR/global.action $CONFDIR/global.action.dpkg-old
65                 fi
66                 (cd $CONFDIR; ln -s match-all.action global.action)
67             fi
68             if grep -q '^actionsfile.*standard.action' $CONFIG
69             then
70                 if [ -e $CONFDIR/standard.action ]
71                 then
72                     if ! grep -q migration $CONFDIR/standard.action
73                     then
74                         mv $CONFDIR/standard.action \
75                             $CONFDIR/standard.action.dpkg-old
76                         echo "# migration file. Not used in 3.0.11 and newer" \
77                             > $CONFDIR/standard.action
78                     fi
79                 else
80                     echo "# migration file. Not used in 3.0.11 and newer" \
81                         > $CONFDIR/standard.action
82                 fi
83             fi
84         fi
85     ;;
86
87     abort-upgrade|abort-remove|abort-deconfigure)
88
89     ;;
90
91     *)
92         echo "postinst called with unknown argument \`$1'" >&2
93         exit 1
94     ;;
95 esac
96
97 # dh_installdeb will replace this with shell code automatically
98 # generated by other debhelper scripts.
99
100 #DEBHELPER#
101
102 exit 0
103
104