#!/bin/sh -e # Source debconf library. . /usr/share/debconf/confmodule db_version 2.0 db_capb backup STATE=1 while [ "$STATE" != 0 -a "$STATE" != 13 ] do case "$STATE" in 1) db_input critical dotlrn/db_host || true if db_go; then db_get dotlrn/db_host || true if [ ! -z "$RET" ]; then STATE=2 fi pg_host="$RET" else STATE=1 fi ;; 2) db_input critical dotlrn/dba_name || true if db_go; then db_get dotlrn/dba_name || true if [ ! -z "$RET" ]; then STATE=3 fi else STATE=1 fi ;; 3) db_input critical dotlrn/dba_password || true if db_go; then db_get dotlrn/dba_password || true STATE=4 else STATE=2 fi ;; 4) db_input critical dotlrn/dba_confirm || true if db_go; then db_get dotlrn/dba_confirm || true CONFIRM="$RET" db_get dotlrn/dba_password || true if [ "$RET" != "$CONFIRM" ]; then STATE=5 else STATE=6 fi else STATE=2 fi ;; 5) db_input critical dotlrn/mismatch || true db_go STATE=3 ;; 6) db_input critical dotlrn/dbu_name || true if db_go; then db_get dotlrn/dbu_name || true if [ ! -z "$RET" ]; then STATE=7 fi pg_user="$RET" else STATE=2 fi ;; 7) db_input critical dotlrn/dbu_password || true if db_go; then db_get dotlrn/dbu_password || true STATE=8 else STATE=6 fi ;; 8) db_input critical dotlrn/dbu_confirm || true if db_go; then db_get dotlrn/dbu_confirm || true CONFIRM="$RET" db_get dotlrn/dbu_password || true if [ "$RET" != "$CONFIRM" ]; then STATE=9 else # Check if host is localhost, user is not www-data and password is not null, # to change the postgresql access permissions properly. if { [ "$pg_host" = "localhost" ] && [ "$pg_user" != "www-data" ]; } then STATE=10 if [ "A$RET" != "A" ]; then pg_pass_blank="false" else pg_pass_blank="true" fi else STATE=11 fi fi else STATE=6 fi ;; 9) db_input critical dotlrn/mismatch || true db_go STATE=6 ;; 10) db_input critical dotlrn/pg_grant_access || true db_go db_get dotlrn/pg_grant_access || true if [ "$RET" = false ]; then if [ "$pg_pass_blank" = "true" ]; then db_input critical dotlrn/pg_grant_access_manual_blank_pass || true else db_input critical dotlrn/pg_grant_access_manual || true fi fi STATE=11 ;; 11) # Check if tsearch tables exists dbname=template1 db_get dotlrn/db_host dbserver="$RET" db_type="postgres7" db_port=5432 db_get dotlrn/dba_name dbadmin="$RET" db_get dotlrn/dba_password dbadmpass="$RET" dbuser=$dbadmin dbpass=$dbadmpass . /usr/share/wwwconfig-common/pgsql.get OUT=$($pgsqlcmd -d $dbname -c "select * from pg_ts_dict, pg_ts_parser, pg_ts_cfg, pg_ts_cfgmap;" 2>/dev/null | head -n1) if [ "x$OUT" = "x" ]; then # Warning tsearch not available db_input critical dotlrn/tsearch_not_enabled || true db_go fi if [ "$status" = "error" ] then err=1 echo $error fi STATE=12 ;; 12) db_input critical dotlrn/create_tables || true db_go STATE=13 ;; esac done if [ "$STATE" = 0 ]; then db_input critical dotlrn/notconfigured || true db_go exit 1 fi