Ask the user if he wants to remove Nextcloud if it appears to be installed previously

This commit is contained in:
dkoao 2019-09-27 16:48:07 +00:00
parent 5cafd91c66
commit 8b6b59be1e
3 changed files with 46 additions and 1 deletions

35
setup/nextcloud-remove.sh Executable file
View File

@ -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

View File

@ -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"

View File

@ -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