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
|
#!/bin/bash
# postinst script for libravatar-seccdn
#
# 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>
# * <postinst> `abort-remove'
# * <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
. /usr/share/debconf/confmodule
APACHE_CONFIG=/etc/libravatar/seccdn.apache2.conf
AWSTATS_CONFIG=/etc/libravatar/awstats.seccdn.conf
AWSTATS_DIR=/var/lib/awstats/seccdn
case "$1" in
configure)
# Make a copy of the templates to work on, then copy into place
cp ${APACHE_CONFIG} ${APACHE_CONFIG}.working
cp ${AWSTATS_CONFIG} ${AWSTATS_CONFIG}.working
for MARKER in __WWWSERVERALIAS__ __CDNSERVERALIAS__ __SECCDNSERVERALIAS__ ; do
# Turns __MARKER__ into marker and puts packagename/ on the front
DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
db_get libravatar-common/$DEBCONF_VAR
VALUE=${RET}
if [ "z${VALUE}" = "z" ] ; then
sed -i -e "s/${MARKER}//g" ${APACHE_CONFIG}.working
else
sed -i -e "s/${MARKER}/ServerAlias ${RET}/g" ${APACHE_CONFIG}.working
fi
done
for MARKER in $(grep -o -E '__[A-Z0-9_]+__' ${APACHE_CONFIG}.working); do
# Turns __MARKER__ into marker and puts packagename/ on the front
DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
db_get libravatar-common/$DEBCONF_VAR || db_get libravatar-seccdn/$DEBCONF_VAR
sed -i -e "s/${MARKER}/${RET}/g" ${APACHE_CONFIG}.working
done
for MARKER in $(grep -o -E '__[A-Z0-9_]+__' ${AWSTATS_CONFIG}.working); do
# Turns __MARKER__ into marker and puts packagename/ on the front
DEBCONF_VAR=$(echo "${MARKER:2:${#MARKER}-4}" | tr '[:upper:]' '[:lower:]')
db_get libravatar-common/$DEBCONF_VAR
sed -i -e "s/${MARKER}/${RET}/g" ${AWSTATS_CONFIG}.working
done
# We a2ensite the site the first time the config is installed, but not after
ENABLE_SITE=""
if [ ! -e /etc/apache2/sites-available/libravatar-seccdn.conf ]; then
ENABLE_SITE="true"
fi
# Enable apache modules we want unconditionally
a2enmod alias > /dev/null 2>&1
a2enmod expires > /dev/null 2>&1
a2enmod headers > /dev/null 2>&1
a2enmod rewrite > /dev/null 2>&1
a2enmod ssl > /dev/null 2>&1
mv ${APACHE_CONFIG}.working /etc/apache2/sites-available/libravatar-seccdn.conf
if [ "$ENABLE_SITE" != "" ]; then
a2ensite libravatar-seccdn
fi
echo ""
echo "Libravatar is now ready for action. You need to restart apache for any"
echo "configuration changes to take effect"
echo ""
mkdir -p /etc/awstats
mv ${AWSTATS_CONFIG}.working /etc/awstats/awstats.seccdn.conf
mkdir -p ${AWSTATS_DIR}
chown www-data:www-data ${AWSTATS_DIR}
;;
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#
db_stop
exit 0
|