[phpBB] svn: r45 - trunk/phpbb2

jeroen at wolffelaar.nl jeroen at wolffelaar.nl
Fri Feb 6 02:26:01 CET 2004


Author: jeroen
Date: 2004-02-06 02:25:31 +0100 (Fri, 06 Feb 2004)
New Revision: 45

Added:
   trunk/phpbb2/phpbb2-conf-mysql.config
   trunk/phpbb2/phpbb2-conf-mysql.postinst
   trunk/phpbb2/phpbb2-conf-mysql.postrm
   trunk/phpbb2/phpbb2-conf-mysql.templates
   trunk/phpbb2/phpbb2.config
   trunk/phpbb2/phpbb2.postinst
   trunk/phpbb2/phpbb2.prerm
   trunk/phpbb2/phpbb2.templates
Removed:
   trunk/phpbb2/postrm
   trunk/phpbb2/prerm
Modified:
   trunk/phpbb2/control
Log:
Split phpbb2-conf-mysql out of phpbb2

Modified: trunk/phpbb2/control
===================================================================
--- trunk/phpbb2/control	2004-02-06 00:56:37 UTC (rev 44)
+++ trunk/phpbb2/control	2004-02-06 01:25:31 UTC (rev 45)
@@ -8,7 +8,7 @@
 Package: phpbb2
 Architecture: all
 Depends: ${misc:Depends}, wwwconfig-common (>= 0.0.33), php4 (>= 4.0.6) | php4-cgi (>= 4.0.6), php4-mysql | php4-pgsql | php4-odbc, apache | httpd, makepasswd
-Suggests: apache, mysql-server
+Recommends: phpbb2-conf-mysql
 Provides: phpbb
 Description: A fully featured and skinneable flat (non-threaded) webforum
  phpBB is a high powered, fully scalable, and highly customisable open-source
@@ -18,3 +18,14 @@
  phpBB is the ideal free community solution for all web sites.
  .
  More info: http://www.phpbb.com
+
+Package: phpbb2-conf-mysql
+Architecture: all
+Depends: phpbb2, php4-mysql, mysql-client
+Recommends: mysql-server
+Description: Automatic configurator for phpbb2 on MySQL database
+ Install this package if you don't want to configure phpBB (package: phpbb2)
+ by hand, but rather want it all to `just work'.
+ .
+ Make sure you have already a MySQL server (either locally or on another
+ server) ready. It's packagename is mysql-server.

Copied: trunk/phpbb2/phpbb2-conf-mysql.config (from rev 36, trunk/phpbb2/config)
===================================================================
--- trunk/phpbb2/config	2004-02-05 00:20:01 UTC (rev 36)
+++ trunk/phpbb2/phpbb2-conf-mysql.config	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,152 @@
+#!/bin/sh
+# config script for phpbb2
+# Copyright 2004 Jeroen van Wolffelaar <jeroen at wolffelaar.nl>
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+db_version 2.0
+db_capb backup
+
+# Flow of questions:
+#
+# prio | detail |  dbms  | dbsetup | Question(s)
+# prio | T C M  | M P O  | C P N   |
+# -----+--------+--------+-------- +-----
+# High |  ASK   |        |         | detail
+# Low  | - - x  |        |         | manual_warning
+# High | - x -  |  ASK   |         | dbms
+# High | - x -  | x x -  |   ASK   | dbsetup
+###### | - x -  | - - x  |         | dbnosetup_warning
+# Mix  | - x -  | x x x  | x x x   | dbinfo
+# High | x x -  | x x -  | x - -   | dbrootpasswd
+
+# Debconf's backup behaviour and seen behaviour makes a state machine almost
+# impossible: seen flags are not update until after this script is finished,
+# so reinjecting and trusting debconf to have unseen the previous question
+# not gonna work -- too bad.
+
+# For now, backing up means starting all over.
+
+if [ -e /etc/phpbb2/config.php ] && [ "$1" = reconfigure ]; then
+	db_reset phpbb2/redodb || true
+	db_input high phpbb2/redodb || true
+	db_go # fail config if cancelling
+	db_get phpbb2/redodb
+	if [ "$RET" = Yes ]; then
+		mv /etc/phpbb2/config.php /etc/phpbb2/config.php.debconf-backup
+	fi
+fi
+
+
+STATE=init
+while [ "$STATE" != "finish" ]; do 
+	case "$STATE" in
+	init)
+		db_input high phpbb2/detail || true
+		db_go # fail config if cancelling
+
+		db_get phpbb2/detail || true
+		DETAIL="$RET"
+		case "$RET" in
+		Custom)	STATE=dbms ;;
+		Manual)	db_input low phpbb2/manual_warning || true
+			if ! db_go; then
+				STATE=init
+			else
+				STATE=finish
+			fi
+			;;
+		Typical)
+			db_reset phpbb2/dbms
+			db_reset phpbb2/dbsetup
+			db_reset phpbb2/dbserver
+			db_reset phpbb2/dbname
+			db_reset phpbb2/dbuser
+			#db_reset phpbb2/dbpass # don't reset, otherwise we forget
+			STATE=dbrootpass
+			;;
+		esac
+		;;
+	dbms)
+		if [ -e /etc/phpbb2/config.php ]; then
+			STATE=finish
+			continue
+		fi
+		db_input high phpbb2/dbms || true
+		if ! db_go; then
+			STATE=init
+			continue
+		fi
+
+		db_get phpbb2/dbms || true
+		if [ ! "$RET" = ODBC ]; then
+			DBMS=MP
+			STATE=dbsetup
+		else
+			DBMS=O
+			STATE=odbc
+		fi
+		;;
+	odbc)
+		db_input medium phpbb2/odbc_warning || true
+		db_go
+		STATE=dbinfo
+		;;
+	dbsetup)
+		db_input high phpbb2/dbsetup || true
+		if db_go; then
+			STATE=dbinfo
+		else
+			STATE=init
+		fi
+
+		db_get phpbb2/dbsetup || true
+		if [ "$RET" = Populate ] || [ "$RET" = None ]; then
+			DBSETUP=PN
+		else
+			DBSETUP=C
+		fi
+		;;
+	dbinfo)
+		db_input high phpbb2/dbserver   || true
+		db_input high phpbb2/dbname   || true
+		db_input high phpbb2/dbuser   || true
+		db_input medium phpbb2/dbpass || true
+		if db_go; then
+			if [ "$DBSETUP" = C ] && [ "$DBMS" = MP ]; then
+				STATE=dbrootpass
+			else
+				STATE=finish
+			fi
+		else
+			STATE=init
+		fi
+		db_get phpbb2/dbpass
+		if [ -z "$RET" ]; then
+			db_set phpbb2/dbpass "`makepasswd --chars 12`"
+		fi
+		;;
+	dbrootpass)
+#		if [ -e /etc/phpbb2/config.php ]; then
+#			STATE=finish
+#			continue
+#		fi
+		db_get phpbb2/db_created
+		if [ "$RET" = "true" ]; then
+			STATE=finish
+			break
+		fi
+		db_input high phpbb2/dbrootpass || true
+		if db_go; then
+			STATE=finish
+		else
+			STATE=init
+		fi
+		;;
+	finish)
+		;;
+	esac
+done
+

Copied: trunk/phpbb2/phpbb2-conf-mysql.postinst (from rev 37, trunk/phpbb2/postinst)
===================================================================
--- trunk/phpbb2/postinst	2004-02-05 01:07:32 UTC (rev 37)
+++ trunk/phpbb2/phpbb2-conf-mysql.postinst	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,147 @@
+#!/bin/bash
+# postinst script for phpbb2
+# By Jeroen van Wolffelaar <jeroen at wolffelaar.nl>
+
+set -e
+
+#export DEBCONF_DEBUG=developer
+
+. /usr/share/debconf/confmodule
+
+db_version 2.0
+
+for i in setup ms server name user pass rootpass; do
+	db_get phpbb2-conf-mysql/db$i || true
+	eval db$i'="$RET"'
+done
+
+
+db_get phpbb2-conf-mysql/detail || true
+# Just to allow breaking out of DB config:
+while true; do
+#
+if [ "$RET" != Manual ]; then
+	db_get phpbb2-conf-mysql/db_created
+	if [ "$dbsetup" = Create ] && [ "$RET" != true ]; then
+			dbadmin=root
+			dbadmpass="$dbrootpass"
+			echo "Creating MySQL database..."
+			. /usr/share/wwwconfig-common/mysql-createdb.sh
+			if [ "$status" = "error" ]; then
+				db_reset phpbb2-conf-mysql/dbfailcreate
+				db_subst phpbb2-conf-mysql/dbfailcreate error $(echo "$error"|head -1)
+				db_input high phpbb2-conf-mysql/dbfailcreate || true
+				db_go || true
+				break
+			fi
+
+			dballow=localhost
+			if [ "$dbserver" != localhost ]; then
+				dballow=%
+			fi
+			echo "Creating MySQL user..."
+			. /usr/share/wwwconfig-common/mysql-createuser.sh 
+			if [ "$status" = "error" ]; then
+				db_reset phpbb2-conf-mysql/dbfailcreateuser
+				db_subst phpbb2-conf-mysql/dbfailcreateuser error $(echo "$error"|head -1) 
+				db_input high phpbb2-conf-mysql/dbfailcreateuser || true
+				db_go || true
+				break
+			fi
+			db_set phpbb2-conf-mysql/db_created true
+	fi
+	if [ "$dbsetup" = Populate ] || [ "$dbsetup" = Create ]; then
+# Okay, being idempotent in creating tables and adding a few rows is extremely
+# hard thing to do. The tables is possible, but those rows? How can one
+# distinguish from not having added a row yet because of a crash, and the row
+# being intermittingly removed/edited by the user
+
+# I'll asume that either the creating/populating of tables succeeds fully or
+# it fails fully
+			dbadmin="$dbuser"
+			dbadmpass="$dbpass"
+			statement='SELECT * FROM phpbb_config"'
+			sqlfile=`mktemp -t phpbb2-conf-mysql.schema.XXXXXX`
+			zcat /usr/share/doc/phpbb2-conf-mysql/schemas/mysql_schema.sql.gz \
+				> $sqlfile
+			zcat /usr/share/doc/phpbb2-conf-mysql/schemas/mysql_basic.sql.gz \
+				>> $sqlfile
+			echo "Creating MySQL tables if they don't exist yet..."
+			. /usr/share/wwwconfig-common/mysql-ifnot-exec.sh
+			rm -f $sqlfile
+			case "$status" in
+			*error)
+				db_reset phpbb2-conf-mysql/dbfailcreatetables || true
+				db_subst phpbb2-conf-mysql/dbfailcreatetables error $(echo "$error"|head -1)
+				db_input high phpbb2-conf-mysql/dbfailcreatetables || true
+				db_go || true
+				break 2
+				;;
+			nothing|exec)
+				db_set phpbb2-conf-mysql/db_version 2.0.6c-1
+				;;
+			*)
+				echo "Unrecognized status from \
+					wwwconfig-common/mysql-ifnot-exec.sh: $status" >&2
+				exit 1
+			esac
+	fi
+			
+	
+fi
+
+# end for allowing breaking out of DB config
+break
+done
+
+# purge database rootpassword
+db_reset phpbb2-conf-mysql/dbrootpass
+
+# Install template if configfile doesn't exist yet
+if [ ! -e /etc/phpbb2/config.php ]; then
+	echo "Creating config file..."
+	tmpfile=`mktemp /etc/phpbb2/config.php.XXXXXX`
+
+	cat <<-NEWCONFIG > $tmpfile
+	<?php
+	// Database configuration file for phpbb2. This file is automatically
+	// generated by debconf on `date -R`
+	
+	/*
+		IMPORTANT:
+
+		In order for automated upgrades in the future to work, you MUST
+		use \`dpkg-reconfigure phpbb2-conf-mysql' for changes to the values in
+		this file. Choose \`Custom' setup, and you will be asked for
+		each of the below parameters.
+
+		If you DO change this file, debconf will not overwrite your
+		changes of course, but you possibly need to upgrade the table
+		definitions by hand then.
+
+	*/
+
+	\$dbms         = "mysql";
+
+	\$dbhost       = "$dbhost";
+	\$dbname       = "$dbname";
+	\$dbuser       = "$dbuser";
+	\$dbpasswd     = "$dbpass";
+
+	\$table_prefix = "phpbb_";
+
+	define('PHPBB_INSTALLED', true);
+
+	?>
+	NEWCONFIG
+
+	mv $tmpfile /etc/phpbb2/config.php
+fi
+
+# fix permissions
+chgrp www-data /etc/phpbb2/config.php
+chmod g=r,o=   /etc/phpbb2/config.php
+
+# Debhelper
+
+#DEBHELPER#

Copied: trunk/phpbb2/phpbb2-conf-mysql.postrm (from rev 27, trunk/phpbb2/postrm)


Property changes on: trunk/phpbb2/phpbb2-conf-mysql.postrm
___________________________________________________________________
Name: svn:executable
   + *

Copied: trunk/phpbb2/phpbb2-conf-mysql.templates (from rev 31, trunk/phpbb2/templates)
===================================================================
--- trunk/phpbb2/templates	2004-02-04 22:58:29 UTC (rev 31)
+++ trunk/phpbb2/phpbb2-conf-mysql.templates	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,113 @@
+Template: phpbb2-conf-mysql/redodb
+Type: select
+Choices: Yes, No
+Default: No
+Description: Do you want to overwrite your current configuration?
+ An existing configuration file for the database has been found as
+ /etc/phpbb2/config.php
+ .
+ Select `Yes' if you want to redo this setup. No database will be destroyed,
+ but any customization of /etc/phpbb2/config.php will be lost.
+
+Template: phpbb2-conf-mysql/dbsetup
+Type: select
+Choices: Create, Populate, None
+Default: Create
+Description: Want configure to create the database?
+ If you haven't created a database with user yet, and want configure to do so,
+ choose `Create'.
+ .
+ If you have a database, but it has no tables yet, and want configure
+ to populate that database with tables, choose `Populate'.
+ .
+ In all other cases, choose `None'.
+
+Template: phpbb2-conf-mysql/dbserver
+Type: string
+Default: localhost
+Description: What is the hostname where your database is running?
+ If your database is on another machine then you need to change this value to
+ the fully qualified domain name for that system.
+
+Template: phpbb2-conf-mysql/dbname
+Type: string
+Default: phpbb2
+Description: What name do you want for database?
+ All users, posts, etc. are stored in one single database. How do you 
+ want to call it?
+
+Template: phpbb2-conf-mysql/dbuser
+Type: string
+Default: phpbb2
+Description: What database username do you want to use?
+ For maximum security, a user dedicated for phpBB will be created.
+
+Template: phpbb2-conf-mysql/dbpass
+Type: password
+Description: What database password do you want to use?
+ Choose a password for the databaseuser.
+ .
+ Leave this empty if you want to have a random password generated.
+
+Template: phpbb2-conf-mysql/dbrootpass
+Type: password
+Description: What is the database-administrator password?
+ In order to create a user, the database and the tables, the
+ database-administrator password is needed.
+ .
+ This password will be temporarily stored by debconf until the configuring
+ phase of this install.  If you do not trust debconf to securily manage this
+ password, configuring phpbb2 will fail and you will need to dpkg-reconfigure
+ this package and choose `Manual'
+
+Template: phpbb2-conf-mysql/dbfailcreate
+Type: note
+Description: FAILURE: Database not created
+ The configuration script failed to create the phpbb database.
+ Please run dpkg-reconfigure phpbb2, to try with different options,
+ possibly choose "Manual" and create the database yourself.
+ .
+ Error:
+ ${error}
+
+Template: phpbb2-conf-mysql/dbfailcreateuser
+Type: note
+Description: FAILURE: Database user not created
+ The configuration script failed to create the phpbb database user.
+ Please run dpkg-reconfigure phpbb2, to try with different options,
+ possibly choose "Manual" and create the database user yourself.
+ .
+ Error:
+ ${error}
+
+Template: phpbb2-conf-mysql/dbfailcreatetables
+Type: note
+Description: FAILURE: Tables not created
+ The configuration script failed to create the phpbb tables.
+ Please run dpkg-reconfigure phpbb2, to try with different options,
+ possibly choose "Manual" and create the tables yourself.
+ .
+ Error:
+ ${error}
+
+Template: phpbb2-conf-mysql/db_created
+Type: select
+Choices: true, false
+Default: false
+Description: [internal] Whether the DB plus user is created
+ phpbb maintainer scripts will not ask for the DB admin password
+ once the db and an accessing user is created
+
+Template: phpbb2-conf-mysql/db_version
+Type: string
+Description: [internal] what db_version is currently setup
+ phpbb scripts will set this value to the current version, so to detect
+ whether it is needed to change database layout, and based on what.
+
+Template: phpbb2-conf-mysql/nodbpurge
+Type: note
+Description: Database not purged
+ The purge script did not drop the database for phpbb, nor the user created
+ for it. You will need to do so yourself (but only if you do not want
+ to loose all data and board configuration).
+

Copied: trunk/phpbb2/phpbb2.config (from rev 36, trunk/phpbb2/config)
===================================================================
--- trunk/phpbb2/config	2004-02-05 00:20:01 UTC (rev 36)
+++ trunk/phpbb2/phpbb2.config	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,13 @@
+#!/bin/sh
+# config script for phpbb2
+# Copyright 2004 Jeroen van Wolffelaar <jeroen at wolffelaar.nl>
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+db_version 2.0
+
+db_input high phpbb2/httpd || true
+db_go
+

Copied: trunk/phpbb2/phpbb2.postinst (from rev 37, trunk/phpbb2/postinst)
===================================================================
--- trunk/phpbb2/postinst	2004-02-05 01:07:32 UTC (rev 37)
+++ trunk/phpbb2/phpbb2.postinst	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,36 @@
+#!/bin/bash
+# postinst script for phpbb2
+# By Jeroen van Wolffelaar <jeroen at wolffelaar.nl>
+
+set -e
+
+#export DEBCONF_DEBUG=developer
+
+. /usr/share/debconf/confmodule
+
+db_version 2.0
+
+#TODO
+# walk though supported apache's, and warn if they are configured but
+# shouldn't anymore
+
+# Maybe store the apache.conf's in the /etc/$apache/conf.d dirs itself, so the
+# user can have distinct configs and such?
+
+# Following lend from phpmyadmin's postinst
+db_get phpbb2/httpd
+webservers="$RET"
+
+for webserver in $webservers; do
+	websever=${webserver%,}
+	if [ -e /etc/$webserver/httpd.conf ] && [ ! -e /etc/$webserver/phpbb2 ]; then
+		mkdir -p /etc/$webserver/conf.d
+		ln -sf /etc/phpbb2/apache.conf /etc/$webserver/conf.d/phpbb2
+	fi
+done
+
+# Offer to reload the changed ones?
+
+# Debhelper
+
+#DEBHELPER#

Copied: trunk/phpbb2/phpbb2.prerm (from rev 31, trunk/phpbb2/prerm)


Property changes on: trunk/phpbb2/phpbb2.prerm
___________________________________________________________________
Name: svn:executable
   + *

Copied: trunk/phpbb2/phpbb2.templates (from rev 31, trunk/phpbb2/templates)
===================================================================
--- trunk/phpbb2/templates	2004-02-04 22:58:29 UTC (rev 31)
+++ trunk/phpbb2/phpbb2.templates	2004-02-06 01:25:31 UTC (rev 45)
@@ -0,0 +1,11 @@
+Template: phpbb2/httpd
+Type: multiselect
+Choices: apache, apache-ssl, apache-perl, apache2
+Default: apache
+Description: What webserver(s) do you want to be configured?
+ phpBB runs on any webserver supporting PHP4. This configuration-script
+ only supports apache-variants. Whiche one(s) do you want to be configured?
+ .
+ Note: You will need to reload (/etc/init.d/apache-??? reload) the
+ webserver(s) by yourself
+

Deleted: trunk/phpbb2/postrm
===================================================================
--- trunk/phpbb2/postrm	2004-02-06 00:56:37 UTC (rev 44)
+++ trunk/phpbb2/postrm	2004-02-06 01:25:31 UTC (rev 45)
@@ -1,49 +0,0 @@
-#! /bin/sh
-# postrm script for phpbb2
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postrm> `remove'
-#        * <postrm> `purge'
-#        * <old-postrm> `upgrade' <new-version>
-#        * <new-postrm> `failed-upgrade' <old-version>
-#        * <new-postrm> `abort-install'
-#        * <new-postrm> `abort-install' <old-version>
-#        * <new-postrm> `abort-upgrade' <old-version>
-#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-. /usr/share/debconf/confmodule
-
-db_version 2.0
-
-case "$1" in
-       purge)
-	   	rm -rf /etc/phpbb2
-		
-		db_reset phpbb2/nodbpurge || true
-		db_input high phpbb2/nodbpurge || true
-		db_go
-
-	   ;;
-	   remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-
-
-        ;;
-
-    *)
-        echo "postrm called with unknown argument \`$1'" >&2
-        exit 1
-
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0

Deleted: trunk/phpbb2/prerm
===================================================================
--- trunk/phpbb2/prerm	2004-02-06 00:56:37 UTC (rev 44)
+++ trunk/phpbb2/prerm	2004-02-06 01:25:31 UTC (rev 45)
@@ -1,44 +0,0 @@
-#! /bin/sh
-# prerm script for phpbb2
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <prerm> `remove'
-#        * <old-prerm> `upgrade' <new-version>
-#        * <new-prerm> `failed-upgrade' <old-version>
-#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
-#        * <deconfigured's-prerm> `deconfigure' `in-favour'
-#          <package-being-installed> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-case "$1" in
-    remove|deconfigure)
-		for webserver in apache apache-ssl apache-perl apache2; do
-			if [ -h /etc/$webserver/conf.d/phpbb2 ]; then
-				rm -f /etc/$webserver/conf.d/phpbb2
-			fi
-		done
-		;;
-    upgrade)
-        ;;
-    failed-upgrade)
-        ;;
-    *)
-        echo "prerm called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-





More information about the phpBB-l mailing list