summaryrefslogtreecommitdiff
path: root/debian/phpbb3.postinst
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2018-03-12 22:57:42 +0100
committerOlivier Gayot <duskcoder@gmail.com>2018-03-12 22:57:42 +0100
commita8c22829d8e8845cd4ddf4ef8b61a1ed79edfffc (patch)
treef0ae554b863266fbe523582d1be09216436c7472 /debian/phpbb3.postinst
Imported from the SVN repository
http://svn.wolffelaar.nl/wsvn/phpbb/branches/jessie/ Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'debian/phpbb3.postinst')
-rwxr-xr-xdebian/phpbb3.postinst184
1 files changed, 184 insertions, 0 deletions
diff --git a/debian/phpbb3.postinst b/debian/phpbb3.postinst
new file mode 100755
index 0000000..6445141
--- /dev/null
+++ b/debian/phpbb3.postinst
@@ -0,0 +1,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#