update_nextcloud.sh: determin PHP_VERSION if not given.

This commit is contained in:
2019-11-16 03:52:41 +01:00
parent 7eeab15a4b
commit ab407905df
2 changed files with 95 additions and 31 deletions

View File

@ -295,10 +295,6 @@ fi
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
if [[ "$PHP_ENGINE" = "FPM" ]] && [[ -z "$PHP_VERSION" ]] ; then
fatal "PHP Version must be givven if running PHP-FPM engine (parameter 'PHP_VERSION')"
fi
if [[ "$DATABASE_TYPE" != "postgres" ]] && [[ "$DATABASE_TYPE" != "mysql" ]]; then
fatal "Wrong or missing database type (parameter 'DATABASE_TYPE')"
fi
@ -317,6 +313,26 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
# Check PHP Version
#
if [[ "$PHP_ENGINE" = "FPM" ]] ; then
if [[ -z "$PHP_VERSION" ]] ; then
if [[ -z "$VHOST_CONFIG_FILE" ]] ; then
if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm"
elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf"
elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf"
fi
fi
PHP_VERSION="$(grep -o -E "php-?.{1}\..{1}-fpm" $VHOST_CONFIG_FILE | grep -o -E ".{1}\..{1}")"
if [[ -z "$PHP_VERSION" ]] ; then
fatal "PHP Version must be givven if running PHP-FPM engine (parameter 'PHP_VERSION')"
fi
fi
fi
# - Determin PHP binary
# -
@ -582,7 +598,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
mkdir ${WEB_BASE_DIR}/nextcloud-${VERSION} > $log_file 2>&1
@ -773,7 +789,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -792,7 +808,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -822,7 +838,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -841,7 +857,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -871,7 +887,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -890,7 +906,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -921,7 +937,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -940,7 +956,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -970,7 +986,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -989,7 +1005,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -1012,7 +1028,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -1043,7 +1059,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -1063,7 +1079,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
@ -1090,7 +1106,7 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
fi
@ -1110,14 +1126,10 @@ else
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
# -----
# - Doing some post-update tasks
# -----
@ -1135,7 +1147,16 @@ if [[ "$PHP_ENGINE" = "FPM" ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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 "Interrupted by user."
fi
else
/etc/init.d/php-${PHP_VERSION}-fpm restart > $log_file 2>&1
@ -1143,7 +1164,16 @@ if [[ "$PHP_ENGINE" = "FPM" ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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 "Interrupted by user."
fi
fi
else
@ -1161,7 +1191,17 @@ if $IS_HTTPD_RUNNING ; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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 "Interrupted by user."
fi
else
/etc/init.d/apache2 start > $log_file 2>&1
@ -1169,7 +1209,16 @@ if $IS_HTTPD_RUNNING ; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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 "Interrupted by user."
fi
fi
else