diff options
Diffstat (limited to 'debian/phpbb3.config')
-rwxr-xr-x | debian/phpbb3.config | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/debian/phpbb3.config b/debian/phpbb3.config new file mode 100755 index 0000000..22d2b5b --- /dev/null +++ b/debian/phpbb3.config @@ -0,0 +1,142 @@ +#!/bin/sh +# config script for phpbb3 +# Copyright 2004 Jeroen van Wolffelaar <jeroen@wolffelaar.nl> +# Copyright 2010 J.M. Roth <jmroth@iip.lu> +# +# possible calls: called from postinst, same calls + reconfigure + +set -e + +if [ "$PB3DEBUG" = "maint" ]; then + echo "[maint] $0 $@" >&2 +fi +if [ "$PB3DEBUG" = "sh" ]; then + set -x +fi + +SUPPORTED_WEBSERVERS="apache2 lighttpd" + +. /usr/share/debconf/confmodule +db_version 2.0 + +# create the list of what webservers we should show in debconf +# (if the dialog is displayed at all) +AVAILABLE_WEBSERVERS="" +for w in $SUPPORTED_WEBSERVERS; do + if [ -x /usr/sbin/$w ]; then + AVAILABLE_WEBSERVERS="${AVAILABLE_WEBSERVERS:+$AVAILABLE_WEBSERVERS, }$w" + fi +done + +# remember previously configured webservers for postinst +# (where we determine which webservers to actually restart) +db_register phpbb3/httpd phpbb3/httpd-old +db_get phpbb3/httpd +db_set phpbb3/httpd-old "$RET" + +db_subst phpbb3/httpd choices $AVAILABLE_WEBSERVERS +db_input high phpbb3/httpd || true +db_go || true + +# some files of the package need to be present to configure the package +if [ -f /usr/share/phpbb3/maint-libs/webapps-config ] && \ + [ -f /usr/share/phpbb3/maint-libs/dbapps-lib ]; then + +. /usr/share/phpbb3/maint-libs/webapps-config +. /usr/share/phpbb3/maint-libs/dbapps-lib + +dc_dbg + +if [ -f /usr/share/dbconfig-common/dpkg/config ]; then + dbc_dbtypes="mysql, pgsql, sqlite" + . /usr/share/dbconfig-common/dpkg/config + + if ! dbc_go phpbb3 $@; then + echo 'dbc_go (config) failed' + fi +fi + +dc_dbg + +# ask to provide board's admin password +# - if dbconfig-common is used at all, and +# - this is a fresh install (or reconfigure), or +# - the password has never been changed from 'admin' +if dc_true phpbb3/dbconfig-install ; then + if [ -n "$2" ] && ! dc_true phpbb3/dbconfig-remove ; then + check_admin_passwd=$(run_sql "SELECT user_password FROM phpbb_users WHERE username='admin';") + fi + + # first ask whether we should ask the questions at all (admin-pass-ask): + # otherwise, when e.g. reconfiguring the _webserver_ one would + # also have to set a new password (NO, in contrary to standard + # dbconfig-common behavior, an empty password here does not mean + # "use the old password" but "generate random password" + case "$1" in + configure ) + case "$2" in + # package install + "" ) + db_set phpbb3/admin-pass-ask true + ;; + # package upgrade/reinstall + * ) + if [ "$check_admin_passwd" = "$(_md5 admin)" ] || dc_true phpbb3/dbconfig-reinstall ; then + db_set phpbb3/admin-pass-ask true + fi + ;; + esac + ;; + # dpkg-reconfigure + reconfigure ) + # database reinstall + if dc_true phpbb3/dbconfig-reinstall ; then + db_set phpbb3/admin-pass-ask true + else + db_input high phpbb3/admin-pass-ask || true + db_go || true + fi + ;; + * ) + db_set phpbb3/admin-pass-ask false + ;; + esac + if dc_true phpbb3/admin-pass-ask ; then + OK=false + until [ "$OK" = "true" ] ; do + dc_forget phpbb3/admin-pass + db_input high phpbb3/admin-pass || true + db_go || true + P1=$(dc_get phpbb3/admin-pass) + if [ -n "$P1" ] ; then + if [ "${#P1}" -lt 6 ] ; then + db_input high phpbb3/admin-pass-requirements && db_go || true + dc_forget phpbb3/admin-pass + dc_forget phpbb3/admin-pass-confirm + continue + fi + db_input high phpbb3/admin-pass-confirm || true + db_go || true + P2=$(dc_get phpbb3/admin-pass-confirm) + if [ "$P1" != "$P2" ] ; then + db_input high phpbb3/admin-pass-mismatch || true + db_go || true + dc_forget phpbb3/admin-pass + dc_forget phpbb3/admin-pass-confirm + continue + fi + else + P2= + P1=$(</dev/urandom tr -dc A-NP-Za-km-z0-9 | head -c 10) + db_subst phpbb3/admin-pass-generated genpass $P1 + db_input high phpbb3/admin-pass-generated || true + db_go || true + db_set phpbb3/admin-pass $P1 + dc_forget phpbb3/admin-pass-generated + fi + OK=true + done + fi + dc_forget phpbb3/admin-pass-ask +fi +fi |