Le mardi 19 février 2008 à 19:20 +0100, Olivier Berger a écrit :
> Hi.
>
> I've tried and find what's going wrong here.
>
> It seems to me that install-pg-db should not create the database, but only
> create the user (with createdb rights maybe, instead of nocreatedb), or,
> otherwise, create the full database and tables, by executing the whole
> /usr/lib/sympa/bin/create_db.Pg, then.
>
> Also, the /usr/lib/sympa/bin/sympa.pl --prepare_db cannot create the database
> at the moment for postgresql from what I could see.
>
> I need to do more tests to figure out what's happening, but this may be an
> option to come to solution of this bug.
>
> Hope this help
>
I think I've indeed found a way to get it to install with postgresql-8.3
(current in testing).
The attached patch provides a way to go, at least from the first tests.
I'm not sure there wouldn't be problems on upgrade, and I'm not sure it
works in all cases, but more testing from others would be great.
Here's the idea to apply the workaround in testing :
1. install postgresql-8.3 and sympa (from unstable package), selecting
"no database" mode for sympa
2. don't change the default postgresql setup : postgres user can connect
without a password, doing "su - postgres" then psql, for instance
3. Apply the provided patch to /usr/share/sympa/db files (prepare_db and
install-pg-db)
4. LANG=C dpkg-reconfigure sympa, and select :
* database : postgresql
* localhost, sympa database, sympa user, a password for sympa user
(twice), and nothing for admin password
The reconfigure/postinst should now :
1. create the sympa user
2. create the database as sympa unix user
3. create the database tables as sympa unix user
4. no longer try the sympa.pl --prepare_db
Then sympa should hopefully start and connect to the PostGres DB
Comments much welcome, of course.
--
Olivier BERGER <[EMAIL PROTECTED]> (*NEW ADDRESS*)
http://www-inf.it-sudparis.eu/~olberger/ - OpenPGP-Id: 1024D/6B829EEC
Ingénieur Recherche - Dept INF
Institut TELECOM / TELECOM & Management SudParis
(http://www.it-sudparis.eu/), Evry
diff -Naur db.orig/install-pg-db db/install-pg-db
--- db.orig/install-pg-db 2008-02-20 11:17:09.0 +0100
+++ db/install-pg-db 2008-02-20 11:14:44.0 +0100
@@ -4,6 +4,17 @@
# Copyright 2000, 2001, 2002 Jérôme Marant <[EMAIL PROTECTED]>
# Copyright 2003, 2004, 2005 Stefan Hornburg (Racke) <[EMAIL PROTECTED]>
+# Args :
+# -d [database] : database to be created (mandatory)
+# -w [user] : user to create database for (mandatory)
+# -u [user_password_file] : provides the path to the file containing the user password (mandatory)
+# -i : connect in Ident mode (-p ignored in this case)
+# -a [admin_password_file] : provides the path to the file containing the admin password
+# -h [host] : postgresql server to connect to (optionnal, by default localhost)
+# -p [port] : port to contact (optionnal, by default 5432)
+# -o [options] : additional connection options (optional)
+#
+
use strict;
use warnings;
@@ -73,24 +84,25 @@
{'RaiseError' => 1});
}
-# Create database
-eval {$dbh->do("CREATE DATABASE $database")};
-
-if ($@) {
- warn "Failed to create database $database: [EMAIL PROTECTED]";
- exit 1;
-}
-
# Create user sympa
#$dbh->do("DELETE FROM pg_shadow WHERE usename='sympa'");
-eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser nocreatedb");};
+#eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser nocreatedb");};
+eval {$dbh->do("CREATE USER $user with password '".$userpass."' nocreateuser createdb");};
if ($@) {
warn "Failed to create user $user: [EMAIL PROTECTED]";
exit 1;
}
+# Create database
+#eval {$dbh->do("CREATE DATABASE $database")};
+
+#if ($@) {
+# warn "Failed to create database $database: [EMAIL PROTECTED]";
+# exit 1;
+#}
+
$dbh->disconnect();
exit 0;
diff -Naur db.orig/prepare_db db/prepare_db
--- db.orig/prepare_db 2008-02-20 11:17:09.0 +0100
+++ db/prepare_db 2008-02-20 11:19:16.0 +0100
@@ -66,7 +66,7 @@
if [ "$RET" ]; then
OPTS="-w $RET $OPTS"
fi
-
+#set -x
case $db_type in
"PostgreSQL")
db_get sympa/db_authtype
@@ -74,22 +74,28 @@
OPTS="-i $OPTS"
fi
/usr/share/sympa/db/install-pg-db $OPTS -d "$db_name" -h "$db_hostname" -u "$userpassfile"
+ su -s /bin/sh sympa -- -c "/usr/bin/createdb -e -O sympa sympa"
+# su -s /bin/sh sympa -- -c "cat /usr/lib/sympa/bin/create_db.Pg | psql -a"
+ su -s /bin/sh sympa -- -c "cat /usr/lib/sympa/bin/create_db.Pg | psql"
+ db_set sympa/db_configured true
;;
"MySQL")
/usr/share/sympa/db/install-mysql-db $OPTS -d "$db_name" -h "$db_hostname" -u "$userpassfile"
+
+ sympaerrors=`tempfile -m 0600`
+
+ if /usr/lib/sympa/bin/sympa.pl -f $conffile --prepare_db 2>$sympaerrors; then
+ db_set sympa/db_configured true
+ rm -f $sympaerrors
+ else
+ cat $sympaerrors
+ echo "Sympa failed to prepare database."
+ rm -f $symp