~libravatar/libravatar/master

148 by Francois Marier
Basic working Debian packaging, ready to be deployed
1
#!/bin/bash
2
# postinst script for libravatar-seccdn
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
#        * <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
20
. /usr/share/debconf/confmodule
21
22
APACHE_CONFIG=/etc/libravatar/seccdn.apache2.conf
445 by Francois Marier
Include awstats config as part of -cdn and -seccdn
23
AWSTATS_CONFIG=/etc/libravatar/awstats.seccdn.conf
24
AWSTATS_DIR=/var/lib/awstats/seccdn
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
25
26
case "$1" in
27
    configure)
445 by Francois Marier
Include awstats config as part of -cdn and -seccdn
28
        # Make a copy of the templates to work on, then copy into place
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
29
        cp ${APACHE_CONFIG} ${APACHE_CONFIG}.working
445 by Francois Marier
Include awstats config as part of -cdn and -seccdn
30
        cp ${AWSTATS_CONFIG} ${AWSTATS_CONFIG}.working
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
31
737 by Francois Marier
Add optional ServerAlias directives in Apache config files
32
        for MARKER in __WWWSERVERALIAS__ __CDNSERVERALIAS__ __SECCDNSERVERALIAS__ ; do
33
            # Turns __MARKER__ into marker and puts packagename/ on the front
34
            DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
35
36
            db_get libravatar-common/$DEBCONF_VAR
37
            VALUE=${RET}
38
            if [ "z${VALUE}" = "z" ] ; then
39
                sed -i -e "s/${MARKER}//g" ${APACHE_CONFIG}.working
40
            else
41
                sed -i -e "s/${MARKER}/ServerAlias ${RET}/g" ${APACHE_CONFIG}.working
42
            fi
43
        done
44
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
45
        for MARKER in $(grep -o -E '__[A-Z0-9_]+__' ${APACHE_CONFIG}.working); do
46
            # Turns __MARKER__ into marker and puts packagename/ on the front
47
            DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
478 by Francois Marier
Make the Apache vhost addresses configurable for cdn and seccdn
48
            db_get libravatar-common/$DEBCONF_VAR || db_get libravatar-seccdn/$DEBCONF_VAR
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
49
            sed -i -e "s/${MARKER}/${RET}/g" ${APACHE_CONFIG}.working
50
        done
445 by Francois Marier
Include awstats config as part of -cdn and -seccdn
51
        for MARKER in $(grep -o -E '__[A-Z0-9_]+__' ${AWSTATS_CONFIG}.working); do
52
            # Turns __MARKER__ into marker and puts packagename/ on the front
53
            DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
54
            db_get libravatar-common/$DEBCONF_VAR
55
            sed -i -e "s/${MARKER}/${RET}/g" ${AWSTATS_CONFIG}.working
56
        done
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
57
58
        # We a2ensite the site the first time the config is installed, but not after
59
        ENABLE_SITE=""
929 by Francois Marier
Update cdn packages for jessie
60
        if [ ! -e /etc/apache2/sites-available/libravatar-seccdn.conf ]; then
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
61
            ENABLE_SITE="true"
62
        fi
63
64
        # Enable apache modules we want unconditionally
65
        a2enmod alias > /dev/null 2>&1
150 by Francois Marier
Make use of mod_expires in the Apache config we ship
66
        a2enmod expires > /dev/null 2>&1
244 by Francois Marier
Make sure mod_headers is enabled
67
        a2enmod headers > /dev/null 2>&1
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
68
        a2enmod rewrite > /dev/null 2>&1
69
        a2enmod ssl > /dev/null 2>&1
70
929 by Francois Marier
Update cdn packages for jessie
71
        mv ${APACHE_CONFIG}.working /etc/apache2/sites-available/libravatar-seccdn.conf
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
72
73
        if [ "$ENABLE_SITE" != "" ]; then
74
            a2ensite libravatar-seccdn
75
        fi
76
77
        echo ""
78
        echo "Libravatar is now ready for action. You need to restart apache for any"
79
        echo "configuration changes to take effect"
80
        echo ""
445 by Francois Marier
Include awstats config as part of -cdn and -seccdn
81
82
        mkdir -p /etc/awstats
83
        mv ${AWSTATS_CONFIG}.working /etc/awstats/awstats.seccdn.conf
84
85
        mkdir -p ${AWSTATS_DIR}
86
        chown www-data:www-data ${AWSTATS_DIR}
148 by Francois Marier
Basic working Debian packaging, ready to be deployed
87
    ;;
88
89
    abort-upgrade|abort-remove|abort-deconfigure)
90
    ;;
91
92
    *)
93
        echo "postinst called with unknown argument \`$1'" >&2
94
        exit 1
95
    ;;
96
esac
97
98
# dh_installdeb will replace this with shell code automatically
99
# generated by other debhelper scripts.
100
101
#DEBHELPER#
102
103
db_stop
104
exit 0