head 1.13; access; symbols OPENPKG_E1_MP:1.3 OPENPKG_E1_MP_HEAD:1.3; locks; strict; comment @# @; 1.13 date 2008.02.29.17.39.41; author rse; state Exp; branches; next 1.12; commitid 6Qvu2VW30GQuQjTs; 1.12 date 2007.09.06.13.30.27; author rse; state Exp; branches; next 1.11; commitid 8ByZGbSDzkhK7Gws; 1.11 date 2007.09.06.09.58.37; author rse; state Exp; branches; next 1.10; commitid upXza4PIVuM4XEws; 1.10 date 2007.09.06.09.50.50; author rse; state Exp; branches; next 1.9; commitid hbhCDPwKryNoUEws; 1.9 date 2007.09.04.17.09.54; author rse; state Exp; branches; next 1.8; commitid jvCu04oxh3C0prws; 1.8 date 2007.08.27.19.00.08; author rse; state Exp; branches; next 1.7; commitid S1aj7BGNYyXLgqvs; 1.7 date 2007.08.27.17.20.26; author rse; state Exp; branches; next 1.6; commitid 3tUSLYweJbBzIpvs; 1.6 date 2007.08.09.10.06.25; author rse; state Exp; branches; next 1.5; commitid Gqo8z0bZBzExT3ts; 1.5 date 2007.08.05.12.01.50; author rse; state Exp; branches; next 1.4; commitid vlonJhpQgAY6Fyss; 1.4 date 2007.08.04.19.32.04; author rse; state Exp; branches; next 1.3; commitid mnWzxvP352Iybtss; 1.3 date 2006.12.13.08.05.21; author rse; state Exp; branches; next 1.2; commitid Lx1OM8zZr5VjUkYr; 1.2 date 2006.12.02.23.48.54; author cs; state Exp; branches; next 1.1; commitid R5C8GuJODsXUt0Xr; 1.1 date 2006.11.24.20.49.24; author rse; state Exp; branches; next ; commitid yPqRsMpP9lDiKXVr; desc @@ 1.13 log @sync with 'drupal' package @ text @#!@@l_bash@@ ## ## dbmail-setup.sh -- DBMail RDBMS Setup Utility ## # command line argument sanity check if [ $# -eq 0 ]; then echo "$0:ERROR: invalid command line" 1>&2 echo "$0:USAGE: $0 install []" 1>&2 echo "$0:USAGE: $0 uninstall" 1>&2 exit 1 fi # package configuration db_type="@@db_type@@" db_script="@@l_prefix@@/share/dbmail/dbmail-setup.sql" # determine database details # FIXME: bail out if extracted values are empty or don't make sense db_dir="@@l_prefix@@/var/dbmail/db" db_name=`grep "^db" @@l_prefix@@/etc/dbmail/dbmail.conf | sed -e 's;^[^=]*= *;;'` db_user=`grep "^user" @@l_prefix@@/etc/dbmail/dbmail.conf | sed -e 's;^[^=]*= *;;'` db_pass=`grep "^pass" @@l_prefix@@/etc/dbmail/dbmail.conf | sed -e 's;^[^=]*= *;;'` # determine RDBMS-specific details if [ ".$db_type" = .sqlite ]; then db_sname="" db_suser="@@l_rusr@@" db_spass="@@l_rgrp@@" elif [ ".$db_type" = .mysql ]; then db_sname="mysql" db_suser=`grep "^user" @@l_prefix@@/etc/mysql/my.pwd |\ sed -e 's;^user[^=]*= *;;' -e 's; *$;;'` db_spass=`grep "^password" @@l_prefix@@/etc/mysql/my.pwd |\ sed -e 's;^password[^=]*= *;;' -e 's; *$;;'` elif [ ".$db_type" = .pgsql ]; then db_sname=`grep "^superuser_database" @@l_prefix@@/var/postgresql/db/pg_superuser.conf |\ sed -e 's;^ *superuser_database="\(.*\)".*;\1;'` db_suser=`grep "^superuser_username" @@l_prefix@@/var/postgresql/db/pg_superuser.conf |\ sed -e 's;^ *superuser_username="\(.*\)".*;\1;'` db_spass=`grep "^superuser_password" @@l_prefix@@/var/postgresql/db/pg_superuser.conf |\ sed -e 's;^ *superuser_password="\(.*\)".*;\1;'` fi # dispatch operation cmd="$1" shift case "$cmd" in install ) # create the DBMail database if [ $# -gt 0 ]; then db_dir="$1" shift fi if [ ".$db_type" = .sqlite ]; then ( umask 077 @@l_prefix@@/bin/sqlite3 $db_name <$db_script chown $db_suser:$db_spass $db_name chmod 640 $db_name ) || exit $? elif [ ".$db_type" = .mysql ]; then # FIXME: MySQL doesn't allow easy relocation of tablespaces AFAIK --rse @@l_prefix@@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name" ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO $db_user@@localhost IDENTIFIED BY '$db_pass';" echo "FLUSH PRIVILEGES;" ) | @@l_prefix@@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname" @@l_prefix@@/bin/mysql --user="$db_user" --password="$db_pass" "$db_name" <$db_script elif [ ".$db_type" = .pgsql ]; then ( echo "CREATE ROLE $db_user LOGIN ENCRYPTED PASSWORD '$db_pass' NOCREATEDB NOCREATEUSER;" echo "CREATE TABLESPACE $db_name OWNER $db_user LOCATION '$db_dir';" echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name ENCODING 'UTF8';" ) | PGPASSWORD="$db_spass" @@l_prefix@@/bin/psql -q -U "$db_suser" -d "$db_sname" -f- PGPASSWORD="$db_pass" @@l_prefix@@/bin/psql -q -U "$db_user" -d "$db_name" -f- <$db_script fi ;; uninstall ) # remove the DBMail database if [ ".$db_type" = .sqlite ]; then rm -f $db_name >/dev/null 2>&1 || true elif [ ".$db_type" = .mysql ]; then ( echo "DROP DATABASE $db_name;" ) | @@l_prefix@@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname" elif [ ".$db_type" = .pgsql ]; then ( echo "DROP DATABASE $db_name;" echo "DROP TABLESPACE $db_name;" echo "DROP ROLE $db_user;" ) | PGPASSWORD="$db_spass" @@l_prefix@@/bin/psql -q -U "$db_suser" -d "$db_sname" -f- fi ;; esac @ 1.12 log @I'm not 100% sure (because the DBMail vendor docs are unclear) but it really looks (dbmail.conf) that DBMail is expecting the database in UTF-8 format, so create the PostgreSQL database with this encoding, too @ text @d64 1 a64 1 ( echo "GRANT ALL ON $db_name.* TO $db_user@@localhost IDENTIFIED BY '$db_pass';" @ 1.11 log @also determine name of superuser databases automatically @ text @d71 1 a71 1 echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name;" @ 1.10 log @use new pg_superuser.conf @ text @d27 1 d31 1 d37 2 d66 1 a66 1 ) | @@l_prefix@@/bin/mysql --user="$db_suser" --password="$db_spass" mysql d72 1 a72 1 ) | PGPASSWORD="$db_spass" @@l_prefix@@/bin/psql -q -U "$db_suser" -d template1 -f- d82 1 a82 1 ) | @@l_prefix@@/bin/mysql --user="$db_suser" --password="$db_spass" mysql d87 1 a87 1 ) | PGPASSWORD="$db_spass" @@l_prefix@@/bin/psql -q -U "$db_suser" -d template1 -f- @ 1.9 log @try to fix the PostgreSQL password reading issue inside a FreeBSD jail (where /dev/tty cannot be opened by psql and hence stdin is used which in turn fails): ask for the password manually and pass it to psql with the PGPASSWORD variable @ text @d35 4 a38 2 db_suser="postgresql" read -s -p "Password for PostgreSQL user \"$db_suser\": " db_spass @ 1.8 log @pass at least the user password in batch (the superuser password still has to be specified interactively) @ text @d1 1 a1 1 #!/bin/sh d36 1 a36 1 db_spass="" # has to be interactive d66 1 a66 1 ) | @@l_prefix@@/bin/psql -q -W -U "$db_suser" -d template1 -f- d81 1 a81 1 ) | @@l_prefix@@/bin/psql -q -W -U "$db_suser" -d template1 -f- @ 1.7 log @try to enforce password prompts @ text @d67 1 a67 1 @@l_prefix@@/bin/psql -q -W -U "$db_user" -d "$db_name" -f- <$db_script @ 1.6 log @be quiet when creation the database in PostgreSQL @ text @d66 2 a67 2 ) | @@l_prefix@@/bin/psql -q -U "$db_suser" -d template1 -f- @@l_prefix@@/bin/psql -q -U "$db_user" -d "$db_name" -f- <$db_script d81 1 a81 1 ) | @@l_prefix@@/bin/psql -q -U "$db_suser" -d template1 -f- @ 1.5 log @allow one to override the database storage location @ text @d66 2 a67 2 ) | @@l_prefix@@/bin/psql -U "$db_suser" -d template1 -f- @@l_prefix@@/bin/psql -U "$db_user" -d "$db_name" -f- <$db_script d81 1 a81 1 ) | @@l_prefix@@/bin/psql -U "$db_suser" -d template1 -f- @ 1.4 log @use 'dbmail' as the database name for MySQL/PosgreSQL and create the database schema under the DBMail user instead of the database superuser as at least under PostgreSQL 8.2 this else would lead to permission problems on the dbmail_xxx tables @ text @d6 8 d40 2 a41 1 cmd="${1:-"install"}" d45 4 @ 1.3 log @fix copy & paste error @ text @d48 1 a48 1 @@l_prefix@@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_name" <$db_script d54 1 a54 1 @@l_prefix@@/bin/psql -U "$db_suser" -d "$db_name" -f- <$db_script @ 1.2 log @some minor fixes, notes and cometics @ text @d3 1 a3 1 ## dbmail-setup.sh -- Sympa RDBMS Setup Utility @ 1.1 log @new package: dbmail 2.2.1 (Fast Scalable RDBMS Mail Server) @ text @d11 1 @