upgrade_roundcube.sh: fix error using internal field separator IFS.
This commit is contained in:
parent
0c4dd7b5e9
commit
0f6fa53e6d
@ -3,6 +3,8 @@
|
|||||||
clear
|
clear
|
||||||
echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m"
|
echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m"
|
||||||
|
|
||||||
|
CUR_IFS="$IFS"
|
||||||
|
|
||||||
## -----------------------------------------------------------------
|
## -----------------------------------------------------------------
|
||||||
## ----------------------------------------------------------------
|
## ----------------------------------------------------------------
|
||||||
## ---
|
## ---
|
||||||
@ -186,6 +188,7 @@ while IFS='' read -r -d '' _conf_file ; do
|
|||||||
fi
|
fi
|
||||||
WEBSITE_NAME=""
|
WEBSITE_NAME=""
|
||||||
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0)
|
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0)
|
||||||
|
IFS="$CUR_IFS"
|
||||||
|
|
||||||
if [[ ${#unsorted_website_arr} -eq 0 ]]; then
|
if [[ ${#unsorted_website_arr} -eq 0 ]]; then
|
||||||
fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
|
fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
|
||||||
@ -194,7 +197,7 @@ fi
|
|||||||
# - Sort array
|
# - Sort array
|
||||||
# -
|
# -
|
||||||
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
|
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
|
||||||
IFS=' '
|
IFS="$CUR_IFS"
|
||||||
|
|
||||||
|
|
||||||
WEBSITE_NAME=
|
WEBSITE_NAME=
|
||||||
@ -208,6 +211,8 @@ for _site in ${website_arr[@]} ; do
|
|||||||
echo " [$i] ${_arr[0]}"
|
echo " [$i] ${_arr[0]}"
|
||||||
((i++))
|
((i++))
|
||||||
done
|
done
|
||||||
|
IFS="$CUR_IFS"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echononl " Eingabe: "
|
echononl " Eingabe: "
|
||||||
while ! $_OK ; do
|
while ! $_OK ; do
|
||||||
@ -223,6 +228,7 @@ read _IN
|
|||||||
echononl " Eingabe: "
|
echononl " Eingabe: "
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
IFS="$CUR_IFS"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echononl " Include Configuration file.."
|
echononl " Include Configuration file.."
|
||||||
@ -234,6 +240,7 @@ else
|
|||||||
echo_ok
|
echo_ok
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
[[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!"
|
[[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!"
|
||||||
|
|
||||||
DEFAULT_WEBSITE_BASEDIR="/var/www/${WEBSITE_NAME}"
|
DEFAULT_WEBSITE_BASEDIR="/var/www/${WEBSITE_NAME}"
|
||||||
@ -278,6 +285,34 @@ if [[ "$DB_TYPE" = "mysql" ]]; then
|
|||||||
else
|
else
|
||||||
[[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)"
|
[[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)"
|
||||||
fi
|
fi
|
||||||
|
mysql_credential_args="$MYSQL_CREDENTIALS"
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$DB_TYPE" = "mysql" ]]; then
|
||||||
|
echononl " Get MySQL command.."
|
||||||
|
mysql_command="$(which mysql)"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
|
||||||
|
if [[ -x "/usr/local/mysql/bin/mysql" ]]; then
|
||||||
|
mysql_command="/usr/local/mysql/bin/mysql"
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fatal "$(cat $tmp_log_file)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [[ "$DB_TYPE" = "pgsql" ]] ; then
|
||||||
|
echononl " Get PostgreSQL command.."
|
||||||
|
psql_command="$(which psql)"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
@ -330,6 +365,7 @@ else
|
|||||||
else
|
else
|
||||||
echo_ok
|
echo_ok
|
||||||
fi
|
fi
|
||||||
|
IFS="$CUR_IFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Get the latest PHP version
|
# - Get the latest PHP version
|
||||||
@ -447,16 +483,44 @@ else
|
|||||||
fatal "Abort by user request - Answer as not 'YES'"
|
fatal "Abort by user request - Answer as not 'YES'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echononl "\tCheck Database connection .."
|
||||||
if [[ "$DB_TYPE" = "mysql" ]]; then
|
if [[ "$DB_TYPE" = "mysql" ]]; then
|
||||||
if ! mysql $MYSQL_CREDENTIALS -N -s -e \
|
${mysql_command} $MYSQL_CREDENTIALS -N -s -e \
|
||||||
"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>> $log_file \
|
"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>> $log_file \
|
||||||
| grep $DB_NAME >> $log_file 2>&1 ; then
|
| grep $DB_NAME >> $log_file 2>&1
|
||||||
fatal "MySQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')"
|
|
||||||
|
if [[ "$?" = "0" ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $log_file)"
|
||||||
|
|
||||||
|
echononl "continue anyway [yes/no]: "
|
||||||
|
read OK
|
||||||
|
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||||
|
echononl "Wrong entry! - repeat [yes/no]: "
|
||||||
|
read OK
|
||||||
|
done
|
||||||
|
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ "$DB_TYPE" = "pgsql" ]]; then
|
elif [[ "$DB_TYPE" = "pgsql" ]]; then
|
||||||
count=$(su - postgres -c "psql -q -A -t -l" | grep -c -e "^$DB_NAME")
|
count=$(su - postgres -c "${psql_command} -q -A -t -l" | grep -c -e "^$DB_NAME")
|
||||||
if [[ $count -eq 0 ]];then
|
if [[ $count -eq 0 ]];then
|
||||||
fatal "PostgreSQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')"
|
echo_failed
|
||||||
|
error "$(cat $log_file)"
|
||||||
|
|
||||||
|
echononl "continue anyway [yes/no]: "
|
||||||
|
read OK
|
||||||
|
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||||
|
echononl "Wrong entry! - repeat [yes/no]: "
|
||||||
|
read OK
|
||||||
|
done
|
||||||
|
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
fatal "Cannot detect database type (value of DB_TYPE is neither 'mysql' nor 'pgsql')"
|
fatal "Cannot detect database type (value of DB_TYPE is neither 'mysql' nor 'pgsql')"
|
||||||
|
Loading…
Reference in New Issue
Block a user