Support script-driven upgrades for version 32.0.x

This commit is contained in:
2025-12-06 13:02:08 +01:00
parent 7efb678dfb
commit b1f7186090
5 changed files with 1752 additions and 31 deletions

View File

@@ -192,17 +192,87 @@ blank_line() {
fi
}
ensure_nc_app() {
local APP_ID="$1"
echononl " Install nextcloud app '$APP_ID'.."
# 1. Prüfen, ob die App überhaupt installiert ist
#
# ${OCC_CMD[@]} expandiert jedes Element des Arrays als eigenes Argument.
#
if ! "${OCC_CMD[@]}" app:list 2>/dev/null | grep -q " - ${APP_ID}:"; then
"${OCC_CMD[@]}" app:install "$APP_ID" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
echo -e "\ncommand was: ${OCC_CMD[@]} app:install \"${APP_ID}\""
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
echo_skipped
fi
echononl " Enable App '${APP_ID}'.."
# 2. Prüfen, ob die App aktiviert ist (nur 'Enabled'-Block betrachten)
local ENABLED_BLOCK
ENABLED_BLOCK="$("${OCC_CMD[@]}" app:list 2>/dev/null \
| awk 'BEGIN{flag=0} /Enabled:/ {flag=1; next} /Disabled:/ {flag=0} flag')"
if echo "$ENABLED_BLOCK" | grep -q " - ${APP_ID}:"; then
echo_skipped
else
"${OCC_CMD[@]}" app:enable "${APP_ID}" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
echo -e "\ncommand was: ${OCC_CMD[@]} app:install \"${APP_ID}\""
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
}
# ----------
# - Jobhandling
# - Jobhandling
# ----------
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
# -
trap clean_up SIGHUP SIGINT SIGTERM
## -
## -
while IFS='' read -r -d '' _conf_file ; do
source $_conf_file
if [[ -n "$WEBSITE" ]] ; then
@@ -226,7 +296,7 @@ IFS=$CUR_IFS
# =============
# --- Some
# --- Some
# =============
# - Support systemd ?
@@ -363,6 +433,10 @@ if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory not found (parameter 'WEB_BASE_DIR')"
fi
if [[ -z "${EXTRA_APPS}" ]]; then
fatal "No list of extra apps (parameter EXTRA_APPS) found!"
fi
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
if [[ "$DATABASE_TYPE" != "postgres" ]] && [[ "$DATABASE_TYPE" != "mysql" ]]; then
@@ -413,6 +487,18 @@ DATA_DIR="$(realpath "${WEB_BASE_DIR}/data")"
OLD_DATA_DIR="$(dirname "${DATA_DIR}")/data-${PRIOR_VERSION}.${backup_date}"
# OCC_CMD Kommando als Array definieren.
#
# Ausführen des Kommandos:
#
# ${OCC_CMD[@]}
#
# ${OCC_CMD[@]} ist die einzig sichere Art, ein Array als Kommando aufzurufen. Jedes Element
# des Arrays als eigenes Argument.
#
OCC_CMD=(sudo -u "$HTTP_USER" "$PHP_BIN" -f "$INSTALL_DIR/occ")
#_CURRENT_DATA_DIR="$(grep datadirectory "${CURRENT_INSTALL_DIR}/config/config.php" 2> /dev/null \
@@ -451,7 +537,7 @@ echo ""
echo -e " Databse name.........................: $DATABASE_NAME"
echo -e " Database type........................: $DATABASE_TYPE"
#echo ""
#echo -e " Install ColaboraOnline App...........: $INSTALL_COLABORA_ONLINE_APP"
#echo -e " Install ColaboraOnline App...........: $INSTALL_COLABORA_ONLINE_APP"
echo ""
if [[ "$DATABASE_TYPE" = "mysql" ]] ; then
echo -e " Mysql Credentials....................: $MYSQL_CREDENTIALS"
@@ -460,7 +546,7 @@ echo ""
if [[ "$VERSION" = "$PRIOR_VERSION" ]] ; then
warn "The new version (\033[1m${VERSION}\033[m) is the same as the current version (\033[1m${PRIOR_VERSION}\033[m).
\033[1mYou have to reinstall some apps manually!\033[m"
fi
@@ -821,8 +907,8 @@ else
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
# - Synchronisiere neues Installationsverzeichnis mit
# - den extrahierten Dateien
# - Synchronisiere neues Installationsverzeichnis mit
# - den extrahierten Dateien
# -
echononl " Sync downloaded (new) nextlcoud int '${INSTALL_DIR}'.."
rsync -a ${SRC_BASE_DIR}/nextcloud/ ${INSTALL_DIR}/ > $log_file 2>&1
@@ -941,7 +1027,7 @@ blank_line
# -
echo ""
echo -e " Update Nextcloud\n"
su -c"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER
su -c"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER
echo ""
if [[ $? -eq 0 ]]; then
info "Updating nextcloud core was successfully.."
@@ -1012,7 +1098,7 @@ if $(systemctl list-units --full -all | grep -Fq "notify_push") ; then
fi
echononl " Enable Nextcloud App 'notify_pushi'.."
echononl " Enable Nextcloud App 'notify_push'.."
if $(
sudo -u "${HTTP_USER}" ${PHP_BIN} -f /${WEB_BASE_DIR}/htdocs/occ app:list --enabled \
| grep -q notify
@@ -1030,7 +1116,7 @@ if $(systemctl list-units --full -all | grep -Fq "notify_push") ; then
fi
echononl " Setup Nextcloud App 'notify_pushi'.."
echononl " Setup Nextcloud App 'notify_push'.."
script -q -c "sudo -u "${HTTP_USER}" ${PHP_BIN} -f /${WEB_BASE_DIR}/htdocs/occ notify_push:setup" /dev/null <<< $'\n' \
> $log_file 2>&1
if [[ $? -eq 0 ]]; then
@@ -1040,10 +1126,22 @@ if $(systemctl list-units --full -all | grep -Fq "notify_push") ; then
fatal "$(cat $log_file)"
fi
blank_line
fi
#
#
# -----
# - Reinstall estra apps
# -----
declare -i index=1
for APP in "${EXTRA_APPS[@]}"; do
[[ ${index} -gt 1 ]] && blank_line
ensure_nc_app "$APP"
(( index++ ))
done
## - Install and enable nextcloud app 'calendar'
## -
#_app="calendar"
@@ -1420,6 +1518,39 @@ echo ""
echo -e "\033[37m\033[1mDoing some post-update tasks..\033[m"
echo ""
echononl " Check if app_api has registered apps .."
EX_APPS_COUNT=$(
sudo -u "${HTTP_USER}" ${PHP_BIN} -f /${WEB_BASE_DIR}/htdocs/occ app_api:app:list 2>/dev/null \
| grep -v "No registered apps" \
| grep -E '^[[:space:]]*[a-zA-Z0-9_-]+[[:space:]]' \
| wc -l
)
DAEMONS_COUNT=$(
sudo -u "${HTTP_USER}" ${PHP_BIN} -f /${WEB_BASE_DIR}/htdocs/occ app_api:daemon:list 2>/dev/null \
| grep -v "No registered daemon configs" \
| grep -E '^[[:space:]]*[a-zA-Z0-9_-]+[[:space:]]' \
| wc -l
)
echo_done
echononl " Disable 'app_api'.."
if [ "${EX_APPS_COUNT}" -eq 0 ] && [ "${DAEMONS_COUNT}" -eq 0 ]; then
sudo -u "${HTTP_USER}" ${PHP_BIN} -f /${WEB_BASE_DIR}/htdocs/occ app:disable app_api > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add missing columns
# -
echononl " Add missing columns .."