diff --git a/helper-scripts/nextcloud.sh b/helper-scripts/nextcloud.sh index 1bba17e1..b4a03eab 100755 --- a/helper-scripts/nextcloud.sh +++ b/helper-scripts/nextcloud.sh @@ -10,6 +10,7 @@ while [ "$1" != '' ]; do case "${1}" in -p|--purge) NC_PURGE=y && shift;; -i|--install) NC_INSTALL=y && shift;; + -u|--update) NC_UPDATE=y && shift;; -h|--help) NC_HELP=y && shift;; *) echo "Unknown parameter: ${1}" && shift;; esac @@ -19,6 +20,7 @@ if [[ ${NC_HELP} == "y" ]]; then printf 'Usage:\n\n' printf ' -p|--purge\n Purge Nextcloud\n' printf ' -i|--install\n Install Nextcloud\n\n' + printf ' -u|--update\n Update Nextcloud\n\n' exit 0 fi @@ -29,99 +31,131 @@ cd ${SCRIPT_DIR}/../ source mailcow.conf if [[ ${NC_PURGE} == "y" ]]; then + read -r -p "Are you sure you want to purge Nextcloud? [y/N] " response + response=${response,,} + if [[ ! "$response" =~ ^(yes|y)$ ]]; then + echo "OK, aborting." + exit 1 + fi - docker exec -it $(docker ps -f name=mysql-mailcow -q) mysql -uroot -p${DBROOT} -e \ - "$(docker exec -it $(docker ps -f name=mysql-mailcow -q) mysql -uroot -p${DBROOT} -e "SELECT GROUP_CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME SEPARATOR ';') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'nc_%' AND TABLE_SCHEMA = '${DBNAME}';" -BN)" - docker exec -it $(docker ps -f name=redis-mailcow -q) /bin/sh -c ' cat < /dev/null 2>&1 ; then + read -p "Cannot ping subdomain, continue anyway? [y|N] " NC_CONT_FAIL + [[ ! ${NC_CONT_FAIL,,} =~ ^(yes|y)$ ]] && { echo "Ok, exiting..."; exit 1; } + fi + fi + ADMIN_NC_PASS=$( /dev/null 2>&1 ; then - read -p "Cannot ping subdomain, continue anyway? [y|N] " NC_CONT_FAIL - [[ ! ${NC_CONT_FAIL,,} =~ ^(yes|y)$ ]] && { echo "Ok, exiting..."; exit 1; } - fi - fi + curl -L# -o nextcloud.tar.bz2 "https://download.nextcloud.com/server/releases/latest-15.tar.bz2" || { echo "Failed to download Nextcloud archive."; exit 1; } \ + && tar -xjf nextcloud.tar.bz2 -C ./data/web/ \ + && rm nextcloud.tar.bz2 \ + && rm -rf ./data/web/nextcloud/updater \ + && mkdir -p ./data/web/nextcloud/data \ + && mkdir -p ./data/web/nextcloud/custom_apps \ + && chmod +x ./data/web/nextcloud/occ - ADMIN_NC_PASS=$(