upgrade_roundcube.sh: support of multiple installation instances.
This commit is contained in:
parent
33f2395025
commit
98b6d1232b
@ -18,8 +18,17 @@ echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m"
|
||||
# - Settings
|
||||
# -------------
|
||||
|
||||
_src_base_dir="$(realpath $(dirname $0))"
|
||||
conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf"
|
||||
#_src_base_dir="$(realpath $(dirname $0))"
|
||||
#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"
|
||||
|
||||
declare -a unsorted_website_arr
|
||||
declare -a website_arr
|
||||
|
||||
curdir=`pwd`
|
||||
|
||||
log_file="$(mktemp)"
|
||||
@ -76,6 +85,17 @@ info (){
|
||||
echo ""
|
||||
}
|
||||
|
||||
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]*}" ]])
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo_ok() {
|
||||
echo -e "\033[85G[ \033[32mok\033[m ]"
|
||||
@ -138,7 +158,51 @@ DEFAULT_DEBIAN_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
|
||||
DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
|
||||
|
||||
|
||||
while IFS='' read -r -d '' _conf_file ; do
|
||||
source $_conf_file
|
||||
if [[ -n "$WEBSITE_NAME" ]] ; then
|
||||
unsorted_website_arr+=("${WEBSITE_NAME}:$_conf_file")
|
||||
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 ""
|
||||
echononl " Include Configuration file.."
|
||||
if [[ ! -f $conf_file ]]; then
|
||||
echo_failed
|
||||
@ -210,14 +274,14 @@ if [[ "$NEW_INSTALL_DIR" = "$CUR_INSTALL_DIR" ]] ; then
|
||||
echononl "Type uppercase \"yes\" to proceed with upgrading: "
|
||||
|
||||
read _proceed
|
||||
[[ "$_proceed" == "YES" ]] || fatal "Exiting by user request.."
|
||||
[[ "${_proceed^^}" = "YES" ]] || fatal "Exiting by user request.."
|
||||
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo -e "\033[1;32mSettings for installation of \033[1;37mRoundcube Webmail\033[m"
|
||||
echo -e "\033[1;32mSettings for upgrading \033[1;37mRoundcube Webmail\033[m"
|
||||
echo ""
|
||||
echo -e "\tRoundcube Version....................: $ROUNDCUBE_VERSION"
|
||||
echo ""
|
||||
@ -308,8 +372,8 @@ fi
|
||||
echo -e "\n\n \033[37m\033[1mDownloud/Unpack source archive..\033[m\n"
|
||||
|
||||
echononl " Download 'roundcubemail-${ROUNDCUBE_VERSION}'.."
|
||||
if [[ ! -f "$_src_base_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then
|
||||
wget -O ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBE_VERSION}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz > $log_file 2>&1
|
||||
if [[ ! -f "$script_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then
|
||||
wget -O ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBE_VERSION}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -321,8 +385,8 @@ else
|
||||
fi
|
||||
|
||||
echononl " Remove existing source directory"
|
||||
if [[ -d "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then
|
||||
rm -rf "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1
|
||||
if [[ -d "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then
|
||||
rm -rf "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -335,7 +399,7 @@ fi
|
||||
|
||||
|
||||
echononl " Unpack roundcube source archive.."
|
||||
gunzip < ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz | tar -C ${_src_base_dir} -xf - > $log_file 2>&1
|
||||
gunzip < ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz | tar -C ${script_dir} -xf - > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -478,7 +542,7 @@ fi
|
||||
|
||||
|
||||
echononl " Change into new roundcube source directory"
|
||||
cd "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1
|
||||
cd "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -487,8 +551,8 @@ else
|
||||
fi
|
||||
|
||||
echononl " Create log-directory for update log file"
|
||||
if [[ ! -d "${_src_base_dir}/log" ]]; then
|
||||
mkdir "${_src_base_dir}/log" > $log_file 2>&1
|
||||
if [[ ! -d "${script_dir}/log" ]]; then
|
||||
mkdir "${script_dir}/log" > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -501,8 +565,8 @@ fi
|
||||
|
||||
echo ""
|
||||
echo " Update the the roundcube web-directory to version '${ROUNDCUBE_VERSION}'"
|
||||
echononl " See: ${_src_base_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log"
|
||||
echo "y" | ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${_src_base_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log 2>&1
|
||||
echononl " See: ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log"
|
||||
echo "y" | ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
@ -520,12 +584,12 @@ else
|
||||
fi
|
||||
|
||||
echononl " Update dependencies by running 'php composer.phar update --no-dev'"
|
||||
php composer.phar update --no-dev > ${_src_base_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log 2>&1
|
||||
php composer.phar update --no-dev > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "$(cat ${_src_base_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log)"
|
||||
error "$(cat ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log)"
|
||||
fi
|
||||
|
||||
echononl " Index build-in addressbook"
|
||||
|
Loading…
Reference in New Issue
Block a user