diff --git a/conf/install_update_dovecot.conf.sample b/conf/install_update_dovecot.conf.sample index b1776a3..dfa78ca 100644 --- a/conf/install_update_dovecot.conf.sample +++ b/conf/install_update_dovecot.conf.sample @@ -86,7 +86,7 @@ database="" # - dbname # - # - Defaults to 'postfix' -#dbname=postfx +#dbname=postfix # - dbuser # - diff --git a/install_update_dovecot.sh b/install_update_dovecot.sh index 6c0b704..87b4a26 100755 --- a/install_update_dovecot.sh +++ b/install_update_dovecot.sh @@ -921,7 +921,25 @@ if $_new ; then if [ "$db_driver" = "pgsql" ]; then - count=`su - postgres -c "psql -q -A -t -l" | grep -c -e "^$dbname"` + echononl "\tCheck if database '$dbname' already exists.." + count=`su - postgres -c "psql -q -A -t -l" 2> ${_log_dir}/error.log | grep -c -e "^$dbname"` + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Checking existence of database '$dbname' failed!" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + + fi + if [ $count -eq 0 ];then echononl "\tCreate database user ${dbuser}.." echo "CREATE ROLE $dbuser WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$dbpassword'" \ @@ -948,7 +966,7 @@ if $_new ; then ## - Create table expires in database ${dbname} ## - echononl "\tCreate table expires in database ${dbname}.." - cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 + cat << EOF | psql -U$dbuser $dbname > ${_log_dir}/error.log 2>&1 CREATE TABLE IF NOT EXISTS expires ( username varchar(100) not null, @@ -962,7 +980,17 @@ EOF echo -e "$rc_done" else echo -e "$rc_failed" - error "Creating table expires failed" + error "$(cat ${_log_dir}/error.log)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi echononl "\tCreate function merge_expires() / trigger mergeexpires.." @@ -989,7 +1017,16 @@ EOF echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Creating function merge_expires() / trigger mergeexpires failed" + error "$(cat ${_log_dir}/error.log)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi elif [ "$db_driver" = "mysql" ]; then @@ -1000,34 +1037,61 @@ EOF echononl "\tCreate database ${dbname}.." mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PW -N -s -e \ - "CREATE DATABASE IF NOT EXISTS $dbname CHARACTER SET utf8 COLLATE utf8_general_ci" > /dev/null 2>&1 + "CREATE DATABASE IF NOT EXISTS $dbname CHARACTER SET utf8 COLLATE utf8_general_ci" > ${_log_dir}/error.log 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Creating database $dbname failed" + error "$(cat ${_log_dir}/error.log)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi echononl "\tCreate database user ${dbuser}.." mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PW -N -s -e \ - "GRANT ALL ON ${dbname}.* TO '${dbuser}'@'localhost' IDENTIFIED BY '$dbpassword'" > /dev/null 2>&1 + "GRANT ALL ON ${dbname}.* TO '${dbuser}'@'localhost' IDENTIFIED BY '$dbpassword'" > ${_log_dir}/error.log 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Creating database user $dbuser failed" + error "$(cat ${_log_dir}/error.log)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi echononl "\tFlushing database privileges.." - mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PW -N -s -e "FLUSH PRIVILEGES" > /dev/null 2>&1 + mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PW -N -s -e "FLUSH PRIVILEGES" > ${_log_dir}/error.log 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Flushing database privileges failed" + error "$(cat ${_log_dir}/error.log)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi fi @@ -3863,6 +3927,19 @@ else fatal "Restarting postfix failed" fi +blank_line +echononl "\tSet '_update=true' in file '$(basename "$conf_file")'.." +if grep -q -E "^\s*_update=false" "$conf_file" 2> /dev/null ; then + perl -i -n -p -e "s/^\s*_update=.*/_update=true/" "$conf_file" + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Adjusting '"$conf_file"' (set _update=true) failed!" + fi +else + echo -e "$rc_skipped" +fi echo -e "