Browse Source

Improve deletion (use full path)

master
Dryusdan 6 months ago
parent
commit
d6c2fd9f1b
1 changed files with 9 additions and 11 deletions
  1. +9
    -11
      nextcloud.sh

+ 9
- 11
nextcloud.sh View File

@ -36,7 +36,7 @@ fatal() { echo -e "${RED}[FATAL] $* ${NC}" | logger --tag "${SCRIPTNAME}" --
########################################################
## Define nextcloud's folder ##########################
FOLDER="/var/www/cloud_drycat_fr"
FOLDER="/var/www/nextcloud/"
## Ask nextcloud ######################################
read -p "Nextcloud version ? " VERSION
@ -46,14 +46,14 @@ info "Check if require folders exist"
if [ -d "${FOLDER}/nextcloud" ]; then
warning "Aborded installation exist. Remove nextcloud/ folder"
rm -rf ${FOLDER}/nextcloud || fatal "Error when removing folder. Exiting"
rm nextcloud-* || fatal "Error when removing nextcloud-* .zip, .zip.sha256, .zip.asc. Please remove $FOLDER/nextcloud and $FOLDER/nextcloud-* and retry"
rm "${FOLDER}"/nextcloud-* || fatal "Error when removing nextcloud-* .zip, .zip.sha256, .zip.asc. Please remove $FOLDER/nextcloud and $FOLDER/nextcloud-* and retry"
fi
if [ -d "${FOLDER}/www" ]; then
info "www/ directory exist, continue"
NEW_INSTALLATION=false
else
warning "www/ directory don't exist, creating"
mkdir ${FOLDER}/www || fatal "Error when creating folder. Exiting"
mkdir "${FOLDER}/www" || fatal "Error when creating folder. Exiting"
NEW_INSTALLATION=true
fi
if [ -d "${FOLDER}/data" ]; then
@ -109,19 +109,17 @@ unzip -q nextcloud-${VERSION}.zip
if [[ ${NEW_INSTALLATION} == "false" ]]; then
info "Unlink folders that contain the data"
cp ${FOLDER}/config/config.php ${FOLDER}/config.php
cp ${FOLDER}/config/config.php ${FOLDER}/config.php
unlink www/data
unlink www/config
unlink www/apps
rm -f ${FOLDER}/apps/workflowengine/appinfo/database.xml
info "Backuping old installation"
tar -zcf "www.$(date '+%Y-%m-%d').tar.gz" www
tar -zcf "apps.$(date '+%Y-%m-%d').tar.gz" apps
info "Removing old installation"
rm -rf www/*
rm -rf "${FOLDER}"/www/*
info "Copying news apps files"
fi
@ -129,9 +127,9 @@ fi
info "Copying new Nextcloud"
cp -rf nextcloud/apps/* apps/
rm -rf nextcloud/{config,data,apps}
cp -rf nextcloud/* www/
cp -rf "${FOLDER}"/nextcloud/apps/* apps/
rm -rf "${FOLDER}"/nextcloud/{config,data,apps}
cp -rf "${FOLDER}"/nextcloud/* www/
cp -rf ${FOLDER}/config.php ${FOLDER}/config/config.php
info "Link folders that contain the data into new installation"
@ -140,7 +138,7 @@ ln -s ${FOLDER}/config ${FOLDER}/www/
ln -s ${FOLDER}/apps ${FOLDER}/www/
info "Removing archive and temp folder"
rm -rf nextcloud-${VERSION}.zip* ../nextcloud/
rm -rf ${FOLDER}/nextcloud-${VERSION}.zip* ${FOLRDER}/nextcloud/
info "Setting good permission"
cd www/


Loading…
Cancel
Save