From 8b6b59be1ea4bc53e11f2e0997ec96f10084f46b Mon Sep 17 00:00:00 2001 From: dkoao Date: Fri, 27 Sep 2019 16:48:07 +0000 Subject: [PATCH] Ask the user if he wants to remove Nextcloud if it appears to be installed previously --- setup/nextcloud-remove.sh | 35 +++++++++++++++++++++++++++++++++++ setup/questions.sh | 9 ++++++++- setup/start.sh | 3 +++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 setup/nextcloud-remove.sh diff --git a/setup/nextcloud-remove.sh b/setup/nextcloud-remove.sh new file mode 100755 index 00000000..7bef4dc7 --- /dev/null +++ b/setup/nextcloud-remove.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# This script will remove Nextcloud from your MiaB server +################################################################## + +source setup/functions.sh # load our functions +source /etc/mailinabox.conf # load global vars + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." + exit +fi + +# Backup the existing ownCloud/Nextcloud. +# Create a backup directory to store the current installation and database to + +BACKUP_DIRECTORY=$STORAGE_ROOT/owncloud-backup/`date +"%Y-%m-%d-%T"` +mkdir -p "$BACKUP_DIRECTORY" +if [ -d /usr/local/lib/owncloud/ ]; then + echo "Backing up existing Nextcloud installation, configuration, and database to directory to $BACKUP_DIRECTORY..." + cp -r /usr/local/lib/owncloud "$BACKUP_DIRECTORY/owncloud-install" + rm -r /usr/local/lib/owncloud +fi +if [ -e $STORAGE_ROOT/owncloud/owncloud.db ]; then + cp $STORAGE_ROOT/owncloud/owncloud.db $BACKUP_DIRECTORY +fi +if [ -e $STORAGE_ROOT/owncloud/config.php ]; then + cp $STORAGE_ROOT/owncloud/config.php $BACKUP_DIRECTORY +fi +if [ -d $STORAGE/owncloud/ ]; then + echo "Removing Nextcloud..." + rm -r $STORAGE_ROOT/owncloud +fi +# Remove Nextcloud's dependencies +apt_purge php-imap php-pear php-dev php-xml php-zip php-apcu php-imagick diff --git a/setup/questions.sh b/setup/questions.sh index a45f4943..69972859 100644 --- a/setup/questions.sh +++ b/setup/questions.sh @@ -203,7 +203,14 @@ if [ ! -d $STORAGE_ROOT/owncloud ]; then \n\nWould you like to disable it?"\ DISABLE_NEXTCLOUD fi - +if [ -d $STORAGE_ROOT/owncloud ]; then + yesno_box "Remove Nextcloud?"\ + "It seems that you already have Nextcloud installed previous\ + \n\nNextcloud offers the Contacts and Calendar features in Mail-in-a-box\ + \nIt also offers other features like file sharing, gallery, todos, and more.\ + \n\nWould you like to remove it?"\ + REMOVE_NEXTCLOUD +fi # Show the configuration, since the user may have not entered it manually. echo echo "Primary Hostname: $PRIMARY_HOSTNAME" diff --git a/setup/start.sh b/setup/start.sh index bd534bf9..34acc9f2 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -104,6 +104,9 @@ source setup/mail-dovecot.sh source setup/mail-users.sh source setup/dkim.sh source setup/spamassassin.sh +if [ "${REMOVE_NEXTCLOUD}" == "0" ] { + source setup/nextcloud-remove.sh +} source setup/web.sh source setup/webmail.sh