Some post installations on update and restore scripts.

This commit is contained in:
Christoph 2023-08-03 10:43:06 +02:00
parent d84294cf0b
commit 2c37b04ddf
3 changed files with 277 additions and 17 deletions

View File

@ -520,7 +520,7 @@ echo -e "\033[37m\033[1mMain part of the script\033[m"
echo "" echo ""
# - Create missing indices # - Add missing primary keys ..
# - # -
echononl " Add missing primary keys .." echononl " Add missing primary keys .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1 su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1

View File

@ -100,7 +100,7 @@ echo_skipped() {
} }
echo_wait(){ echo_wait(){
if $terminal ; then if $terminal ; then
echo -en "\033[75G[ \033[5m\033[1m...\033[m ]" echo -en "\033[75G[ \033[5m\033[1m..\033[m ]"
fi fi
} }
fatal (){ fatal (){
@ -727,7 +727,7 @@ fi
# - Restore Database # - Restore Database
# - # -
echononl " Restore Database - \033[5m\033[1mmay take a long time\033[m" echononl " Restore Database \033[5m\033[1mmay take a long time\033[m"
echo_wait echo_wait
if [[ "$DATABASE_TYPE" = 'mysql' ]]; then if [[ "$DATABASE_TYPE" = 'mysql' ]]; then
mysql $MYSQL_CREDENTIALS $DATABASE_NAME < \ mysql $MYSQL_CREDENTIALS $DATABASE_NAME < \
@ -784,8 +784,90 @@ fi
echo "" echo ""
echo "" echo ""
echo -e "\033[37m\033[1mDoing some post-script tasks..\033[m" echo -e "\033[37m\033[1mDoing some post-script tasks..\033[m"
echo "" echo ""
# - Add missing columns
# -
echononl " Add missing columns .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
# - Create missing indices
# -
echononl " Add missing indices .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
# - Add missing primary keys ..
# -
echononl " Add missing primary keys .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
echononl " Run cronjob manually.."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/cron.php" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
blank_line
echononl " Restart PHP engine.." echononl " Restart PHP engine.."
if [[ "$PHP_ENGINE" = "FPM" ]]; then if [[ "$PHP_ENGINE" = "FPM" ]]; then
if $SYSTEMD_EXISTS ; then if $SYSTEMD_EXISTS ; then

View File

@ -402,7 +402,7 @@ INSTALL_DIR="${WEB_BASE_DIR}/nextcloud-${VERSION}"
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)" CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
#PRIOR_VERSION="$(basename $CURRENT_INSTALL_DIR | cut -d"-" -f2)" #PRIOR_VERSION="$(basename $CURRENT_INSTALL_DIR | cut -d"-" -f2)"
PRIOR_VERSION="$(sudo -u $HTTP_USER /usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)" PRIOR_VERSION="$(sudo -u $HTTP_USER ${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)"
#DATA_DIR=${WEB_BASE_DIR}/data-${VERSION} #DATA_DIR=${WEB_BASE_DIR}/data-${VERSION}
#CURRENT_DATA_DIR="$(realpath ${WEB_BASE_DIR}/data-$PRIOR_VERSION)" #CURRENT_DATA_DIR="$(realpath ${WEB_BASE_DIR}/data-$PRIOR_VERSION)"
@ -662,7 +662,7 @@ if $NGINX_IS_ENABLED ; then
fi fi
fi fi
echo "" blank_line
# - Backup Database # - Backup Database
# - # -
@ -701,11 +701,18 @@ elif [[ "$DATABASE_TYPE" = 'postgres' ]]; then
echo_ok echo_ok
else else
echo_failed echo_failed
fatal "$(cat $log_file)" error "$(cat $log_file)"
fi
fi
echo 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
# - Backup old installation directory # - Backup old installation directory
@ -717,8 +724,19 @@ if [[ $? -eq 0 ]]; then
else else
echo_failed echo_failed
error "$(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
blank_line
# - Remove symlink from old installation directory # - Remove symlink from old installation directory
# - # -
@ -728,7 +746,16 @@ if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed 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
@ -760,7 +787,16 @@ if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed 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
# - Kopiere Verzeichnis "config" in das neue Installationsverzeichnis # - Kopiere Verzeichnis "config" in das neue Installationsverzeichnis
@ -822,7 +858,16 @@ if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed 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
@ -834,7 +879,16 @@ if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed 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
# - Set Permissions on new data directory # - Set Permissions on new data directory
@ -845,7 +899,16 @@ if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed 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
@ -858,20 +921,52 @@ if [[ $? -eq 0 ]]; then
else else
echo_failed echo_failed
error "$(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
blank_line
# - Update Nextcloud # - Update Nextcloud
# - # -
echo "" echo ""
echo " Update Nextcloud" echo " Update Nextcloud"
su -c"/usr/local/php/bin/php ${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
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
info "Updating nextcloud core was successfully.." info "Updating nextcloud core was successfully.."
else else
fatal "$(cat $log_file)" fatal "$(cat $log_file)"
fi fi
# Set maintenace mode to 'off'.. !!
#
blank_line
echononl " Set maintenace mode to 'off'.."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ maintenance:mode --off" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
blank_line
## ----- ## -----
@ -1258,8 +1353,91 @@ fi
echo "" echo ""
echo "" echo ""
echo -e "\033[37m\033[1mDoing some post-update tasks..\033[m" echo -e "\033[37m\033[1mDoing some post-update tasks..\033[m"
echo "" echo ""
# - Add missing columns
# -
echononl " Add missing columns .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
# - Create missing indices
# -
echononl " Add missing indices .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
# - Add missing primary keys ..
# -
echononl " Add missing primary keys .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
echononl " Run cronjob manually.."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/cron.php" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 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 "Interrupted by user."
fi
blank_line
echononl " Restart PHP engine.." echononl " Restart PHP engine.."
if [[ "$PHP_ENGINE" = "FPM" ]]; then if [[ "$PHP_ENGINE" = "FPM" ]]; then
if $SYSTEMD_EXISTS ; then if $SYSTEMD_EXISTS ; then