+diogenes (0.9.20-2) unstable; urgency=low
+
+ * Switch to dbconfig-common for database setup.
+
+ -- Jeremy Lainé <jeremy.laine@m4x.org> Sun, 5 Nov 2006 12:03:28 +0100
+
diogenes (0.9.20-1) unstable; urgency=low
* New upstream release.
Package: diogenes
Architecture: all
-Depends: ${misc:Depends}, libphp-diogenes (= ${Source-Version}), gettext, wwwconfig-common (>=0.0.41), apache | apache2 | httpd, php4-cli | php5-cli, php-pear | php4-pear, cvs, rcs, perl-modules, ucf (>=0.28)
+Depends: ${misc:Depends}, libphp-diogenes (= ${Source-Version}), gettext, dbconfig-common, apache | apache2 | httpd, php4-cli | php5-cli, php-pear | php4-pear, cvs, rcs, perl-modules, ucf (>=0.28)
Recommends: mysql-server
Suggests: wv
Description: web content management system
#!/bin/bash -e
-RANDOMDEVICE=/dev/urandom
-allowed=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./
-declare -a RVAL
-
-second () {
- echo $2
-}
-
-create-random-pw() {
- if ! read -n 0 < $RANDOMDEVICE ; then
- echo 1>&2 "Warning, no random device found, password might be insecure"
- for i in 0 1 2 3 4 5 6 7; do
- RVAL[i]=$RANDOM
- done
- else
- for i in 0 1 2 3 4 5 6 7; do
- RVAL[i]=$(second $(od -N 1 -t d $RANDOMDEVICE))
- done
- fi
-
- PW=""
- for i in 0 1 2 3 4 5 6 7; do
- idx=$((${RVAL[i]} & 0x3F))
- PW="${PW}${allowed:$idx:1}"
- done
-
- printf "%s" $PW
-}
-
# this function comes from wwwconfig-common's apache.func script
getwwwoption() {
getwwwoption=""
db_set "diogenes/webgroup" "$webgroup"
fi
-db_input "high" "diogenes/databasemgr_type" || true
-db_go
-db_get "diogenes/databasemgr_type"
-dbtype="$RET"
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
+ . /usr/share/dbconfig-common/dpkg/config.mysql
+ dbc_go diogenes $@
+fi
-if [ "$dbtype" = "Automatic" ] ; then
- db_input "high" "diogenes/databasemgr_server" || true
- db_go
- db_input "high" "diogenes/dbmyadmin" || true
- db_go
- db_input "critical" "diogenes/dbadmpass" || true
- db_go
- db_input "medium" "diogenes/database_name" || true
- db_go
- db_input "medium" "diogenes/database_user" || true
- db_go
- db_input "medium" "diogenes/database_pass" || true
- db_go
- db_get "diogenes/database_pass"
- dbpass="$RET"
- if [ "$dbpass" = "auto" ]; then
- dbpass=$(create-random-pw)
- elif [ "$dbpass" = "none" ]; then
- dbpass=""
- fi
- db_set "diogenes/database_pass" "$dbpass"
-fi
--- /dev/null
+#!/bin/sh -e
+
+updatedb=/usr/share/diogenes/scripts/updatedb.php
+dbconfig=/etc/dbconfig-common/diogenes.conf
+
+if [ ! -f "$dbconfig" ]; then
+ echo "Could not find config file : $dbconfig"
+ exit 0
+fi
+
+. $dbconfig
+if [ -z "$dbc_dbserver" ]; then
+ dbc_dbserver="localhost"
+fi
+
+if [ -x "$updatedb" ]; then
+ $updatedb -q -s "$dbc_dbserver" -d "$dbc_dbname" -u "$dbc_dbuser" -p "$dbc_dbpass"
+fi
#! /bin/sh
-# Horde postinst script using debconf
+# Diogenes postinst script using debconf and dbconfig-common
# Written by Ola Lundqvist <opal@debian.org>
# Adapted for Horde2 by Nils Rennebarth <nils@debian.org>
# Adapted for Diogenes by Jeremy Lainé <jeremy.laine@m4x.org>
create_file_from_template() {
infile=$1
outfile=$2
+ if [ -f /etc/dbconfig-common/diogenes.conf ]; then
+ . /etc/dbconfig-common/diogenes.conf
+ fi
+ # If dbc_dbserver is empty, use localhost
+ if [ -z "$dbc_dbserver" ]; then
+ dbc_dbserver="localhost"
+ fi
# Password may contain anything, so we need to descend to quoting
# hell.
- safepass="$dbpass"
+ safepass="$dbc_dbpass"
# quote normal quote and final backslash because we need to write
# a single quoted PHP string
safepass=$(echo "$safepass" | sed -e "s/'/\\\\'/g" -e 's/\\$/\\\\'/)
# we use the hash sign as a delimiter
safepass=$(echo "$safepass" | sed -e 's/#/\\#/g')
sed -e " \
- s#@dbname@#$dbname#; \
- s#@dbserver@#$dbserver#; \
- s#@dbuser@#$dbuser#; \
+ s#@dbname@#$dbc_dbname#; \
+ s#@dbserver@#$dbc_dbserver#; \
+ s#@dbuser@#$dbc_dbuser#; \
s#@dbpass@#$safepass#; \
" <$infile >$outfile
}
+# get debconf started
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/postinst.mysql ]; then
+ . /usr/share/dbconfig-common/dpkg/postinst.mysql
+ dbc_go diogenes $@
+fi
case "$1" in
configure)
ucf --debconf-ok /usr/share/diogenes/config/diogenes.debian.inc.php /etc/diogenes/diogenes.debian.inc.php
ucf --debconf-ok /usr/share/diogenes/config/apache.conf /etc/diogenes/apache.conf
-# get debconf started
-. /usr/share/debconf/confmodule
-db_version 2.0
-
-###############################################################################
-############################### Configure database ############################
-###############################################################################
-
-# Type of the databasemgr to use.
-db_get "diogenes/databasemgr_type"
-dbtype="$RET"
-if [ "$dbtype" = "Automatic" ] ; then
- # Where it is located.
- db_get "diogenes/databasemgr_server"
- dbserver="$RET"
- # Name of the database
- db_get "diogenes/database_name"
- dbname="$RET"
- # Name of the user to have access.
- db_get "diogenes/database_user"
- dbuser="$RET"
- # Its password.
- db_get "diogenes/database_pass"
- dbpass="$RET"
-
- if [ ! -z $(which mysql) ]; then
-
- # retrieve admin user and password
- db_get "diogenes/dbmyadmin"
- dbadmin="$RET"
- db_get "diogenes/dbadmpass"
- dbadmpass="$RET"
- db_reset "diogenes/dbadmpass"
-
- . /usr/share/wwwconfig-common/mysql-createdb.sh
- if [ "$status" = "create" ] ; then
- sqlfile=/usr/share/diogenes/scripts/diogenes.tables.sql
- create_file_from_template $sqlfile.in $sqlfile
- . /usr/share/wwwconfig-common/mysql-exec.sh
- rm $sqlfile
- sqlfile=/usr/share/diogenes/scripts/diogenes.logactions.sql
- create_file_from_template $sqlfile.in $sqlfile
- . /usr/share/wwwconfig-common/mysql-exec.sh
- rm $sqlfile
- elif [ "$status" = "nothing" ] ; then
- if ! /usr/share/diogenes/scripts/updatedb.php -q -s "$dbserver" -d "$dbname" -u "$dbadmin" -p "$dbadmpass" ; then
- echo "There was an error while upgrading the Diogenes database."
- fi
- else
- echo $error
- fi
- . /usr/share/wwwconfig-common/mysql-createuser.sh
- else
- echo "Not configuring MySQL database because we cannot locate"
- echo "the mysql client executable (mysql-client package missing)."
- fi
-else
- echo "Not configuring MySQL database at your request."
-fi
-
-
###############################################################################
########################## Configure web servers ##############################
###############################################################################
# If necessary, add a symlink to our apache.conf
if [ -d /etc/$server/conf.d ] && [ ! -e /etc/$server/conf.d/diogenes ] ; then
ln -s $includefile /etc/$server/conf.d/diogenes
- restart="$server $restart"
+ restart_servers="$server $restart_servers"
fi
done
###############################################################################
############################# Servers restart #################################
###############################################################################
-if ! eval . /usr/share/wwwconfig-common/restart.sh ; then
- echo "There was a problem restarting web server(s)."
-fi
+if [ -n "$restart_servers" ]; then
+ for server in $restart_servers; do
+ if [ -x /etc/init.d/$server ]; then
+ if which invoke-rc.d >/dev/null 2>&1; then
+ invoke-rc.d $server reload
+ else
+ /etc/init.d/$server reload
+ fi
+ fi
+ done
+fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
#!/bin/sh -e
-# Horde postrm script using debconf
+# Diogenes postrm script using debconf
# Originally written for horde by Ola Lundqvist <opal@debian.org>
# Adapted for horde2 by Nils Rennebarth <nils@debian.org>
# Adapted for Diogenes by Jeremy Lainé <jeremy.laine@m4x.org>
servers="$server $servers"
if [ -s /etc/$server/conf.d/diogenes ] ; then
rm -f /etc/$server/conf.d/diogenes
- restart="$server $restart"
+ restart_servers="$server $restart_servers"
fi
done
# Restart servers
- if [ -e /usr/share/wwwconfig-common/restart.sh ] ; then
- . /usr/share/wwwconfig-common/restart.sh
+ if [ -n "$restart_servers" ]; then
+ for server in $restart_servers; do
+ if [ -x /etc/init.d/$server ]; then
+ if which invoke-rc.d >/dev/null 2>&1; then
+ invoke-rc.d $server reload
+ else
+ /etc/init.d/$server reload
+ fi
+ fi
+ done
fi
}
+. /usr/share/debconf/confmodule
+db_version 2.0
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/postrm.mysql ]; then
+ . /usr/share/dbconfig-common/dpkg/postrm.mysql
+ dbc_go diogenes $@
+fi
+
ACTION=$1
case "$ACTION" in
remove)
- #
- # Remove Diogenes from the webserver configuration
- #
- . /usr/share/debconf/confmodule
- db_version 2.0
#
# Only try to remove Diogenes from the webserver configs if the db key
;;
purge)
- . /usr/share/debconf/confmodule
- db_version 2.0
#
# Remove ucf-managed files
if [ "$RET" = "true" ]; then
# remove files
rm -rf /var/spool/diogenes /var/lib/diogenes
-
- # drop the database if we are Automatic mode
- db_get "diogenes/databasemgr_type"
- if [ "$RET" = "Automatic" ] ; then
- db_get "diogenes/databasemgr_server"
- dbserver="$RET"
- db_get "diogenes/database_name"
- dbname="$RET"
- # we use the Diogenes user as the "admin", as he is authorized to do a drop
- db_get "diogenes/database_user"
- dbadmin="$RET"
- db_get "diogenes/database_pass"
- dbadmpass="$RET"
- if [ -f /usr/share/wwwconfig-common/mysql.get ] && [ -x $(which mysql) ] ; then
- . /usr/share/wwwconfig-common/mysql.get
- if eval $mysqlcmd -f -e "\"DROP DATABASE $dbname;\"" ; then
- status=dropped
- fi
- fi
- fi
fi
;;
#!/bin/sh -e
+. /usr/share/debconf/confmodule
+db_version 2.0
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/prerm.mysql ]; then
+ . /usr/share/dbconfig-common/dpkg/prerm.mysql
+ dbc_go diogenes $@
+fi
+
ACTION=$1
case "$ACTION" in
remove)
+++ /dev/null
-# establish connection to database
-
-connect @dbname@;
-
DEB_INSTALL_CHANGELOGS_libphp-diogenes := include/diogenes/ChangeLog
#directories
-DEB_INSTALL_DIRS_diogenes := etc/diogenes var/lib/diogenes var/spool/diogenes/templates_c var/spool/diogenes/diogenes_c
+DEB_INSTALL_DIRS_diogenes := etc/diogenes var/lib/diogenes var/spool/diogenes/templates_c var/spool/diogenes/diogenes_c usr/share/dbconfig-common/data/diogenes/install usr/share/dbconfig-common/scripts/diogenes/upgrade/mysql
binary-install/diogenes::
# config
usr/share/diogenes
# files for db installation
- cat debian/prefix.sql config/db/diogenes.sql \
- > debian/diogenes/usr/share/diogenes/scripts/diogenes.tables.sql.in
- cat debian/prefix.sql config/db/diogenes.logactions.sql \
- > debian/diogenes/usr/share/diogenes/scripts/diogenes.logactions.sql.in
+ cat config/db/diogenes.sql config/db/diogenes.logactions.sql > debian/diogenes/usr/share/dbconfig-common/data/diogenes/install/mysql
+ #cp debian/diogenes.dbc-upgrade debian/diogenes/usr/share/dbconfig-common/scripts/diogenes/upgrade/mysql/0.9.20-2
+ #chmod +x debian/diogenes/usr/share/dbconfig-common/scripts/diogenes/upgrade/mysql/0.9.20-2
# remove library files
rm -rf debian/diogenes/usr/share/diogenes/include/diogenes