#!/usr/bin/env bash # renovate: datasource=github-releases depName=nextcloud/server versioning=semver extractVersion=^v(?.*)$ NEXTCLOUD_VERSION=25.0.2 for bin in curl dirmngr; do if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi done [[ -z ${1} ]] && NC_HELP=y while [ "$1" != '' ]; do case "${1}" in -p|--purge) NC_PURGE=y && shift;; -i|--install) NC_INSTALL=y && shift;; -r|--resetpw) NC_RESETPW=y && shift;; -h|--help) NC_HELP=y && shift;; *) echo "Unknown parameter: ${1}" && shift;; esac done if [[ ${NC_HELP} == "y" ]]; then printf 'Usage:\n\n' printf ' -p|--purge\n Purge Nextcloud\n' printf ' -i|--install\n Install Nextcloud\n' printf ' -r|--resetpw\n Reset password\n\n' exit 0 fi [[ ${NC_PURGE} == "y" ]] && [[ ${NC_INSTALL} == "y" ]] && { echo "Cannot use -p and -i at the same time!"; exit 1; } [[ ${NC_PURGE} == "y" ]] && [[ ${NC_RESETPW} == "y" ]] && { echo "Cannot use -p and -r at the same time!"; exit 1; } SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 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 IFNULL(GROUP_CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME SEPARATOR ';'),'SELECT NULL;') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'oc_%' 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 ADMIN_NC_PASS=$(