From d6c2fd9f1be7b1b91d83d8e4819f82f9bd36aa83 Mon Sep 17 00:00:00 2001 From: Dryusdan Date: Fri, 9 Apr 2021 14:30:53 +0200 Subject: [PATCH] Improve deletion (use full path) --- nextcloud.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/nextcloud.sh b/nextcloud.sh index 1285d1e..f7f68a6 100644 --- a/nextcloud.sh +++ b/nextcloud.sh @@ -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/