install_roundcube.sh: add support for installing multiple roundcube webmailer.

This commit is contained in:
Christoph 2020-12-02 18:33:21 +01:00
parent ba1fc4ee1b
commit ff5b0732eb

View File

@ -19,8 +19,20 @@ echo -e "\n\t\033[32mStart script for installation Roundcube Webmailer..\033[m"
# ------------- # -------------
_src_base_dir="$(realpath $(dirname $0))" _src_base_dir="$(realpath $(dirname $0))"
#_src_base_dir=/usr/local/src/postfixadmin
conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf"
script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
#conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf"
declare -a unsorted_website_arr
declare -a website_arr
curdir=`pwd` curdir=`pwd`
log_file="$(mktemp)" log_file="$(mktemp)"
@ -86,6 +98,16 @@ echo_skipped() {
echo -e "\033[75G[ \033[30m\033[1mskipped\033[m ]" echo -e "\033[75G[ \033[30m\033[1mskipped\033[m ]"
} }
is_number() {
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
# - also possible
# -
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
#return $([[ ! -z "${1##*[!0-9]*}" ]])
}
trap clean_up SIGHUP SIGINT SIGTERM trap clean_up SIGHUP SIGINT SIGTERM
@ -127,9 +149,49 @@ if [[ -z "$APACHE_SERVICE_FILE" ]] ; then
fi fi
if [ "$DB_TYPE" = "postgres" -o "$DB_TYPE" = "postgresql" -o "$DB_TYPE" = "pgsql" -o "$DB_TYPE" = "psql" ];then while IFS='' read -r -d '' _conf_file ; do
DB_TYPE=pgsql source $_conf_file
if [[ -n "$WEBSITE_NAME" ]] ; then
unsorted_website_arr+=("${WEBSITE_NAME}:$_conf_file")
fi fi
WEBSITE_NAME=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0)
if [[ ${#unsorted_website_arr} -eq 0 ]]; then
fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
fi
# - Sort array
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
WEBSITE_NAME=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
echo echo
echononl "\tInclude Configuration file.." echononl "\tInclude Configuration file.."