Improve deletion (use full path)
This commit is contained in:
parent
bd1c5ea2c0
commit
d6c2fd9f1b
20
nextcloud.sh
20
nextcloud.sh
|
@ -36,7 +36,7 @@ fatal() { echo -e "${RED}[FATAL] $* ${NC}" | logger --tag "${SCRIPTNAME}" --
|
||||||
########################################################
|
########################################################
|
||||||
|
|
||||||
## Define nextcloud's folder ##########################
|
## Define nextcloud's folder ##########################
|
||||||
FOLDER="/var/www/cloud_drycat_fr"
|
FOLDER="/var/www/nextcloud/"
|
||||||
|
|
||||||
## Ask nextcloud ######################################
|
## Ask nextcloud ######################################
|
||||||
read -p "Nextcloud version ? " VERSION
|
read -p "Nextcloud version ? " VERSION
|
||||||
|
@ -46,14 +46,14 @@ info "Check if require folders exist"
|
||||||
if [ -d "${FOLDER}/nextcloud" ]; then
|
if [ -d "${FOLDER}/nextcloud" ]; then
|
||||||
warning "Aborded installation exist. Remove nextcloud/ folder"
|
warning "Aborded installation exist. Remove nextcloud/ folder"
|
||||||
rm -rf ${FOLDER}/nextcloud || fatal "Error when removing folder. Exiting"
|
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
|
fi
|
||||||
if [ -d "${FOLDER}/www" ]; then
|
if [ -d "${FOLDER}/www" ]; then
|
||||||
info "www/ directory exist, continue"
|
info "www/ directory exist, continue"
|
||||||
NEW_INSTALLATION=false
|
NEW_INSTALLATION=false
|
||||||
else
|
else
|
||||||
warning "www/ directory don't exist, creating"
|
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
|
NEW_INSTALLATION=true
|
||||||
fi
|
fi
|
||||||
if [ -d "${FOLDER}/data" ]; then
|
if [ -d "${FOLDER}/data" ]; then
|
||||||
|
@ -109,19 +109,17 @@ unzip -q nextcloud-${VERSION}.zip
|
||||||
|
|
||||||
if [[ ${NEW_INSTALLATION} == "false" ]]; then
|
if [[ ${NEW_INSTALLATION} == "false" ]]; then
|
||||||
info "Unlink folders that contain the data"
|
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/data
|
||||||
unlink www/config
|
unlink www/config
|
||||||
unlink www/apps
|
unlink www/apps
|
||||||
rm -f ${FOLDER}/apps/workflowengine/appinfo/database.xml
|
|
||||||
|
|
||||||
|
|
||||||
info "Backuping old installation"
|
info "Backuping old installation"
|
||||||
tar -zcf "www.$(date '+%Y-%m-%d').tar.gz" www
|
tar -zcf "www.$(date '+%Y-%m-%d').tar.gz" www
|
||||||
tar -zcf "apps.$(date '+%Y-%m-%d').tar.gz" apps
|
tar -zcf "apps.$(date '+%Y-%m-%d').tar.gz" apps
|
||||||
|
|
||||||
info "Removing old installation"
|
info "Removing old installation"
|
||||||
rm -rf www/*
|
rm -rf "${FOLDER}"/www/*
|
||||||
|
|
||||||
info "Copying news apps files"
|
info "Copying news apps files"
|
||||||
fi
|
fi
|
||||||
|
@ -129,9 +127,9 @@ fi
|
||||||
|
|
||||||
|
|
||||||
info "Copying new Nextcloud"
|
info "Copying new Nextcloud"
|
||||||
cp -rf nextcloud/apps/* apps/
|
cp -rf "${FOLDER}"/nextcloud/apps/* apps/
|
||||||
rm -rf nextcloud/{config,data,apps}
|
rm -rf "${FOLDER}"/nextcloud/{config,data,apps}
|
||||||
cp -rf nextcloud/* www/
|
cp -rf "${FOLDER}"/nextcloud/* www/
|
||||||
cp -rf ${FOLDER}/config.php ${FOLDER}/config/config.php
|
cp -rf ${FOLDER}/config.php ${FOLDER}/config/config.php
|
||||||
|
|
||||||
info "Link folders that contain the data into new installation"
|
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/
|
ln -s ${FOLDER}/apps ${FOLDER}/www/
|
||||||
|
|
||||||
info "Removing archive and temp folder"
|
info "Removing archive and temp folder"
|
||||||
rm -rf nextcloud-${VERSION}.zip* ../nextcloud/
|
rm -rf ${FOLDER}/nextcloud-${VERSION}.zip* ${FOLRDER}/nextcloud/
|
||||||
|
|
||||||
info "Setting good permission"
|
info "Setting good permission"
|
||||||
cd www/
|
cd www/
|
||||||
|
|
Loading…
Reference in New Issue