Improve deletion (use full path)
This commit is contained in:
parent
bd1c5ea2c0
commit
d6c2fd9f1b
18
nextcloud.sh
18
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
|
||||
|
@ -113,15 +113,13 @@ if [[ ${NEW_INSTALLATION} == "false" ]]; then
|
|||
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…
Reference in New Issue