From b92afaa917b12d7eddfb1bc286c101b76ce35819 Mon Sep 17 00:00:00 2001 From: janw Date: Tue, 16 Sep 2008 16:25:56 +0000 Subject: [PATCH] Add debconf stuff to automagic creation of database. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12490 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/debian/gosa-si-server.postinst | 32 ++++++++++++++++++++++++++ gosa-si/debian/rules | 2 +- gosa-si/debian/templates | 31 ++++++++++++------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/gosa-si/debian/gosa-si-server.postinst b/gosa-si/debian/gosa-si-server.postinst index ccbf8c3c9..cae8615a6 100644 --- a/gosa-si/debian/gosa-si-server.postinst +++ b/gosa-si/debian/gosa-si-server.postinst @@ -1,5 +1,18 @@ #!/bin/sh +set -e + +. /usr/share/debconf/confmodule + +db_version 2.0 + +for i in hostname database username password rootpw; do + db_get gosa-si/db$i || true + eval db$i'="$RET"' +done + +dbhost="127.0.0.1" + #DEBHELPER# # We exit unless the package is being configured @@ -11,9 +24,28 @@ case "$1" in *) exit 0; esac +# Setup database +/usr/bin/mysqladmin -u root --password="$rootpw" create "$database" &> /dev/null +/usr/bin/mysql -u root --password="$rootpw" -e "GRANT ALL PRIVILEGES ON $database.* to \'$username\'@\'127.0.0.1\' identified by '$password'" + # Fix permission [ -f /etc/gosa-si/server.conf ] && chmod go-rwx /etc/gosa-si/server.conf +# Apply DB settings to config file +if [ -w /etc/gosa-si/server.conf ]; then + for i in database username password host; do + eval 'val=$'$i + grep -E "$i" /etc/gosa-si/server.conf | grep -vE '^ *#' + if [ $? -eq 0 ]; then + sed -i "/\[server\]/,/\[/s/mysql-$i\s*=\s*\(.*\)$/mysql-$i = $val/g" /etc/gosa-si/server.conf + else + sed -i " + /\[server\]/ a\ +mysql-$i = $val" /etc/gosa-si/server.conf + fi + done +fi + # Restart daemon invoke-rc.d gosa-si restart diff --git a/gosa-si/debian/rules b/gosa-si/debian/rules index 892de833c..96893b185 100755 --- a/gosa-si/debian/rules +++ b/gosa-si/debian/rules @@ -65,7 +65,7 @@ binary-indep: install dh_installchangelogs dh_installman dh_installlogrotate - #dh_installdebconf + dh_installdebconf dh_installinit --init-script=gosa-si -- start 00 2 3 4 5 . stop 29 1 . chmod 640 debian/gosa-si-server/etc/gosa-si/server.conf debian/gosa-si-client/etc/gosa-si/client.conf diff --git a/gosa-si/debian/templates b/gosa-si/debian/templates index 369fd9743..119524367 100644 --- a/gosa-si/debian/templates +++ b/gosa-si/debian/templates @@ -1,29 +1,28 @@ +Template: gosa-si/hostname +Type: string +Default: 127.0.0.1 +Description: Hostname or IP of the MySQL-Server + Please enter the full-qualified hostname or IP Address of the desired MySQL Host. + Template: gosa-si/database Type: string Default: gosa_si -_Description: Name of the GOsa-SI Database +Description: Name of the GOsa-SI Database Please choose a name for the gosa-si database. -Template: gosa-si/host -Type: boolean -Default: true -_Description: Does the database server run on this host? - Please choose if the database server runs on this host or not. - -Template: gosa-si/automagic -Type: boolean -Default: true -_Description: Should the database be created? - Please choose if you want the setup to create the gosa-si database - and a privileged user account. - Template: gosa-si/username Type: string Default: gosa_si -_Description: Name of the GOsa-SI Database User +Description: Name of the GOsa-SI Database User Please choose a name for the gosa-si database user. Template: gosa-si/password Type: password -_Description: Password for the GOsa-SI Database User +Description: Password for the GOsa-SI Database User Please enter a password for the gosa-si database user. + +Template: gosa-si/rootpw +Type: password +Description: Password for the Database Administrator 'root' + In order to create the privileged account, setup needs the password of the + database administrator. Please enter the password of the database user 'root'. -- 2.30.2