update_nextcloud.sh: support reinstall cuurent version.

This commit is contained in:
Christoph 2021-12-11 02:39:45 +01:00
parent 35383599ec
commit a677f31043

View File

@ -576,7 +576,6 @@ CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
#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=23.0.0
#DATA_DIR=${WEB_BASE_DIR}/data-${VERSION}
#CURRENT_DATA_DIR="$(realpath ${WEB_BASE_DIR}/data-$PRIOR_VERSION)"
@ -629,6 +628,10 @@ if [[ "$DATABASE_TYPE" = "mysql" ]] ; then
fi
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)!"
fi
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
read OK
@ -859,10 +862,34 @@ fi
echo
# - Backup old installation directory
# -
echononl " Backup old installation directory"
mv "$CURRENT_INSTALL_DIR" "${CURRENT_INSTALL_DIR}.$backup_date" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
# - Remove symlink from old installation directory
# -
echononl " Remove symlink from old installation directory"
rm ${WEB_BASE_DIR}/nextcloud > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
# - Erstelle Web-Verzeichnis für die neue OwnCloud Version
# -
echononl " Create (new) dir '${WEB_BASE_DIR}/nextcloud-${VERSION}'.."
mkdir "${WEB_BASE_DIR}/nextcloud-${VERSION}" > $log_file 2>&1
mkdir "${INSTALL_DIR}" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
@ -878,12 +905,22 @@ else
done
[[ $OK = "yes" ]] || fatal "Interrupted by user."
fi
mkdir ${WEB_BASE_DIR}/nextcloud-${VERSION} > $log_file 2>&1
# - Set symlink (documentroot) for new installation directory
# -
echononl " Set symlink (documentroot) for new installation directory"
ln -s nextcloud-${VERSION} ${WEB_BASE_DIR}/nextcloud > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
# - Kopiere Verzeichnis "config" in das neue Installationsverzeichnis
# -
echononl " Copy old config into '${WEB_BASE_DIR}/nextcloud-${VERSION}'.."
cp -a ${CURRENT_INSTALL_DIR}/config $INSTALL_DIR/ > $log_file 2>&1
cp -a ${CURRENT_INSTALL_DIR}.${backup_date}/config $INSTALL_DIR/ > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
@ -966,44 +1003,6 @@ else
fi
## - Backup old data directory
## -
#echononl " Backup old data directory"
#_old_data_dir="$(realpath ${WEB_BASE_DIR}/data)"
#mv "$_old_data_dir" "${_old_data_dir}.$backup_date" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
# echo_failed
# error "$(cat $log_file)"
#fi
#
#
#
## - Delete symlink for old data directory
## -
#echononl " Remove symlink from old data dir 'data-${PRIOR_VERSION}'.."
#rm ${WEB_BASE_DIR}/data > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
# echo_failed
# fatal "$(cat $log_file)"
#fi
#
#
## - Set symlink for new data directory
## -
#echononl " Set symlink for new data dir 'data-${VERSION}'.."
#ln -s data-${VERSION} ${WEB_BASE_DIR}/data > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
# echo_failed
# fatal "$(cat $log_file)"
#fi
# - Set Parameter 'datadirectory' to '${DATA_DIR}' .."
# -
echononl " Set Parameter 'datadirectory' to '${DATA_DIR}'"
@ -1016,42 +1015,6 @@ else
fi
# - Backup old installation directory
# -
echononl " Backup old installation directory"
_old_install_dir="$(realpath ${WEB_BASE_DIR}/nextcloud)"
mv "$_old_install_dir" "${_old_install_dir}.$backup_date" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
# - Remove symlink from old installation directory
# -
echononl " Remove symlink from old installation directory"
rm ${WEB_BASE_DIR}/nextcloud > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
# - Set symlink (documentroot) for new installation directory
# -
echononl " Set symlink (documentroot) for new installation directory"
ln -s nextcloud-${VERSION} ${WEB_BASE_DIR}/nextcloud > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
# - Update Nextcloud
# -
echo ""