reopen 372898
tags 372898 patch
thanks

Hi again,

Michael Ablassmeier <[EMAIL PROTECTED]> (12/06/2006):
> On Mon, Jun 12, 2006 at 02:32:38PM +0200, Thomas Huriaux wrote:
> > Your package currently configures a database using MySQL or PostgreSQL
> > or both.
> > 
> > Therefore, it uses debconf to prompt users for information about the
> > databases, database administrator, database name, etc.
> > 
> > A dedicated package for this task has been created recently by Sean
> > Finney, named "dbconfig-common".
> > 
> > This package brings common methods for database servers interactions as
> > well as standardized templates for prompting information.
> 
> hm, im sorry? The zabbix-server-mysql Package already uses said
> dbconfig-common. The only packages asking for database user and so on
> are the client/front-end packages which need to write those settings
> into their config files,

I was indeed talking about this last one.

> but are unlikely installed on the same host as
> the server package, therefore no debconf question sharing.

Why not? See the attached patch. Please note that (i) it's the first
time I'm trying to use dbconfig-common, so there may be wrong things
(it's mainly inspired from the cacti package) and (ii) the patch is
incomplete, you should also remove the corresponding templates, run
debconf-updatepo, etc. I haven't done it to reduce the size (and
improve the readability) of the patch.

Cheers,

-- 
Thomas Huriaux
diff -Nur zabbix-1.1.old/debian/templates/db.inc.php.in 
zabbix-1.1/debian/templates/db.inc.php.in
--- zabbix-1.1.old/debian/templates/db.inc.php.in       2006-06-13 
01:08:33.000000000 +0200
+++ zabbix-1.1/debian/templates/db.inc.php.in   2006-06-13 00:38:24.000000000 
+0200
@@ -22,14 +22,7 @@
 
 // DATABASE CONFIGURATION
 
-//     $DB_TYPE        ="POSTGRESQL";
-       $DB_TYPE        ="@dbtype@";
-       $DB_SERVER      ="@dbserver@";
-       $DB_DATABASE    ="@dbname@";
-//     $DB_DATABASE    ="osmiy";
-//     $DB_DATABASE    ="demo";
-       $DB_USER        ="@dbuser@";
-       $DB_PASSWORD    ="@dbpass@";
+require('/etc/zabbix/debian.php');
 // END OF DATABASE CONFIGURATION
 
 //     $USER_DETAILS   ="";
diff -Nur zabbix-1.1.old/debian/zabbix-frontend-php.config 
zabbix-1.1/debian/zabbix-frontend-php.config
--- zabbix-1.1.old/debian/zabbix-frontend-php.config    2006-06-13 
01:08:33.000000000 +0200
+++ zabbix-1.1/debian/zabbix-frontend-php.config        2006-06-13 
01:09:59.000000000 +0200
@@ -2,23 +2,14 @@
 . /usr/share/debconf/confmodule
 db_version 2.0 || [ $? -lt 30 ]
 
-if [ "$1" = "configure" ]; then
-
-       db_input medium zabbix-frontend-php/database-type || true
-       db_go || true
-
-       db_input medium zabbix-frontend-php/database-server || true
-       db_go || true
+. /usr/share/dbconfig-common/dpkg/config.mysql
+dbc_first_version="1.1-4"
+dbc_load_include="php:/etc/zabbix/debian.php"
+dbc_load_include_args="--dbname=DB_DATABASE --dbpass=DB_PASSWORD 
--dbuser=DB_USER --dbserver=DB_SERVER --dbtype=DB_TYPE"
+dbc_go zabbix-frontend-php $@
 
-       db_input medium zabbix-frontend-php/database-name || true
-       db_go || true
+if [ "$1" = "configure" ]; then
 
-       db_input medium zabbix-frontend-php/database-user || true
-       db_go || true
-    
-       db_input medium zabbix-frontend-php/database-password || true
-       db_go || true
-       
        db_input medium zabbix-frontend-php/reconfigure-webserver || true
        db_go || true
 
diff -Nur zabbix-1.1.old/debian/zabbix-frontend-php.postinst 
zabbix-1.1/debian/zabbix-frontend-php.postinst
--- zabbix-1.1.old/debian/zabbix-frontend-php.postinst  2006-06-13 
01:08:33.000000000 +0200
+++ zabbix-1.1/debian/zabbix-frontend-php.postinst      2006-06-13 
01:10:08.000000000 +0200
@@ -4,36 +4,16 @@
 
 . /usr/share/debconf/confmodule
 db_version 2.0 || [ $? -lt 30 ]
+. /usr/share/dbconfig-common/dpkg/postinst.mysql
+dbc_first_version="1.1-4"
+dbc_generate_include="php:/etc/zabbix/debian.php"
+dbc_generate_include_owner="root:www-data"
+dbc_generate_include_perms="0640"
+dbc_generate_include_args="--dbname=DB_DATABASE --dbpass=DB_PASSWORD 
--dbuser=DB_USER --dbserver=DB_SERVER --dbtype=DB_TYPE"
+dbc_go zabbix-frontend-php $@
 
 if [ "$1" = "configure" ]; then
 
-    # configuration for db.inc.php
-    RET=""
-       db_get zabbix-frontend-php/database-type || true
-       db_type="$RET"
-    sed -i "s/[EMAIL PROTECTED]@/$db_type/g" $CONFFILE 2> /dev/null
-
-    RET=""
-       db_get zabbix-frontend-php/database-server || true
-       db_server="$RET"
-    sed -i "s/[EMAIL PROTECTED]@/$db_server/g" $CONFFILE 2> /dev/null
-
-    RET=""
-       db_get zabbix-frontend-php/database-name || true
-       db_name="$RET"
-    sed -i "s/[EMAIL PROTECTED]@/$db_name/g" $CONFFILE 2> /dev/null
-
-    RET=""
-       db_get zabbix-frontend-php/database-user || true
-       db_user="$RET"
-    sed -i "s/[EMAIL PROTECTED]@/$db_user/g" $CONFFILE 2> /dev/null
-
-    RET=""
-    db_get zabbix-frontend-php/database-password || true
-    db_password="$RET"
-    [ "$db_password" = "none" ] && db_password=""
-    sed -i "s/[EMAIL PROTECTED]@/$db_password/g" $CONFFILE 2> /dev/null
-
     db_get zabbix-frontend-php/reconfigure-webserver || true
     webservers="$RET"
     restart=""
diff -Nur zabbix-1.1.old/debian/zabbix-frontend-php.postrm 
zabbix-1.1/debian/zabbix-frontend-php.postrm
--- zabbix-1.1.old/debian/zabbix-frontend-php.postrm    2006-06-13 
01:08:33.000000000 +0200
+++ zabbix-1.1/debian/zabbix-frontend-php.postrm        2006-06-13 
00:42:02.000000000 +0200
@@ -4,6 +4,9 @@
         . /usr/share/debconf/confmodule
 fi
 
+. /usr/share/dbconfig-common/dpkg/postrm.mysql
+dbc_go zabbix-frontend-php $@
+
 case "$1" in
     failed-upgrade|abort-install|abort-upgrade|disappear|upgrade)
     ;;
@@ -42,6 +45,8 @@
     ;;
     purge)
            db_purge
+          ucf --purge /etc/zabbix/debian.php
+          rm -f /etc/zabbix/debian.php
     ;;
 
     *)

Attachment: signature.asc
Description: Digital signature

Reply via email to