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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
#!/bin/sh
# postinst script for phpbb3
# By Jeroen van Wolffelaar <jeroen@wolffelaar.nl> and J.M. Roth <jmroth@iip.lu>
#
# possible calls: configure, abort-upgrade, abort-remove, abort-deconfigure
set -e
if [ "$PB3DEBUG" = "maint" ]; then
echo "[maint] $0 $@" >&2
dbc_debug=true
fi
if [ "$PB3DEBUG" = "sh" ]; then
set -x
fi
randminmax () {
local min=$1
local max=$2
local var=0
while ([ "$var" -le $min ] || [ "$var" -ge $max ]); do
var=$(dd if=/dev/urandom count=1 2>/dev/null | cksum | cut -c1-2)
done
echo $var
}
if [ "$1" = "configure" ]; then
## libraries
. /usr/share/phpbb3/maint-libs/webapps-config
. /usr/share/phpbb3/maint-libs/dbapps-lib
. /usr/share/debconf/confmodule # calls phpbb3.config
. /usr/share/dbconfig-common/dpkg/postinst
db_version 2.0
# have to do this here since we cannot convert from a directory
# to a link by simple means between versions
ln -fs /var/lib/phpbb3/images /usr/share/phpbb3/www/
## set random background for captcha (J.M.Roth 2010)
RANDX=$(randminmax 10 25)
RANDY=$(randminmax 5 25)
DBCCP=/usr/share/dbconfig-common/data/phpbb3
cp -a /usr/share/phpbb3/dbconfig-common/data/phpbb3 /usr/share/dbconfig-common/data/
for i in mysql pgsql sqlite; do
sed -i "s/@DEB_CAPTCHA_X_RAND@/${RANDX}/" $DBCCP/install/$i
sed -i "s/@DEB_CAPTCHA_Y_RAND@/${RANDY}/" $DBCCP/install/$i
done
UCF=ucf
## DATABASE SETUP
dbc_generate_include="php:/etc/phpbb3/database.inc.php"
dbc_generate_include_owner="root:www-data"
dbc_generate_include_perms="0640"
# for sqlite: make sure that the database is readable for the webserver
dbc_dbfile_owner="root:www-data"
dbc_dbfile_perms="0660"
dc_dbg
if ! dbc_go phpbb3 $@ ; then
echo 'Automatic configuration using dbconfig-common failed!'
else
postgres_update_seqs
# act on the provided admin password
if dc_true phpbb3/dbconfig-install ; then
pass=$(dc_get phpbb3/admin-pass)
if [ -n "$pass" ] ; then
echo "Setting admin password" >&2
run_sql "UPDATE phpbb_users SET user_password='$(_md5 $pass)' WHERE username='admin';"
if [ "$ERR" != "fail" ] && [ "${DEBIAN_FRONTEND}" = "noninteractive" ]; then
echo "Admin password set to $pass" >&2
fi
fi
dc_forget phpbb3/admin-pass
dc_forget phpbb3/admin-pass-confirm
fi
fi
dc_dbg
# /etc/apache2/conf.d/phpbb3.conf symlink moved to /etc/apache2/conf-available
if dpkg --compare-versions "$2" lt-nl "3.0.11-5"; then
[ -L /etc/apache2/conf.d/phpbb3.conf ] && rm /etc/apache2/conf.d/phpbb3.conf
fi
## WEBSERVER SETUP
# initially inspired from phpmyadmin's postinst
webservers=$(dc_get phpbb3/httpd)
reload=""
# determine inexistant, removed, added and non-changed webservers
webservers_old_tmp=$(dc_get phpbb3/httpd-old)
db_reset phpbb3/httpd-old
db_unregister phpbb3/httpd-old
# remove servers from list that don't exist anymore anyhow
# db_reset in phpbb3.config should have sufficed
#webservers_old=""
#for ow in $webservers_old_tmp; do
# ow=${ow%,}
# for aw in $AVAILABLE_WEBSERVERS; do
# aw=${aw%,}
# if [ "$ow" = "$aw" ] ; then
# webservers_old="$webservers_old $ow"
# break
# fi
# done
#done
# find removed servers (elements from old list not in new list)
for ow in $webservers_old_tmp; do
ow=${ow%,}
for w in $webservers; do
w=${w%,}
[ "$ow" = "$w" ] && continue 2
done
reload="$reload $ow"
done
# find added servers (elements from new list not in old list)
for w in $webservers; do
w=${w%,}
for ow in $webservers_old_tmp; do
ow=${ow%,}
[ "$ow" = "$w" ] && continue 2
done
reload="$reload $w"
done
# if we're all but reconfigured,
# everything that is selected has to be reloaded anyhow
if [ -z "$DEBCONF_RECONFIGURE" ] ; then
for webserver in $webservers; do
webserver=${webserver%,}
reload="$reload $webserver"
done
fi
## to correctly account for the case in which
## webservers have been chosen to be NO LONGER configured
## (e.g. via dpkg-reconfigure)
# first, remove all symlinks
purge_webserver_config phpbb3 all 50
# then restore all selected configs
for webserver in $webservers; do
webserver=${webserver%,}
test -x /usr/sbin/$webserver || continue
$UCF --debconf-ok --three-way /usr/share/phpbb3/webserver-examples/$webserver.conf /etc/phpbb3/$webserver.conf
ucfr phpbb3 /etc/phpbb3/$webserver.conf
install_webserver_config phpbb3 $webserver 50
done
# finally reload the changed servers
for r in $reload; do
reload_webserver phpbb3 $r
done
if [ ! -h /usr/share/phpbb3/www/install-* ]; then
ln -s /usr/share/phpbb3/install /usr/share/phpbb3/www/install-$(</dev/urandom tr -dc A-NP-Za-km-z0-9 | head -c 10)
fi
# set permissions that are appropriate for multisite too
chgrp www-data /var/lib/phpbb3/images/avatars/upload
chmod g=wx,o= /var/lib/phpbb3/images/avatars/upload
chmod 0755 /var/lib/phpbb3/images/ranks
chgrp -R www-data /var/cache/phpbb3/cache
for i in $(find /var/cache/phpbb3/cache -type d); do
chmod g=rwx,o= $i
done
chgrp www-data /var/lib/phpbb3/files
chmod g=wx,o= /var/lib/phpbb3/files
chgrp www-data /var/lib/phpbb3/store
chmod g=wx,o= /var/lib/phpbb3/store
fi
# Replace example directory with symlink
# cannot be dropped before Jessie gets released
docdir="/usr/share/doc/phpbb3/examples"
if [ -d $docdir ] && [ ! -L $docdir ]; then
if rmdir $docdir 2>/dev/null; then
ln -sf ../../phpbb3/webserver-examples $docdir
fi
fi
#DEBHELPER#
|