diff --git a/nextcloud.sh b/nextcloud.sh index e40b345..855c2ed 100644 --- a/nextcloud.sh +++ b/nextcloud.sh @@ -43,45 +43,45 @@ read -p "Nextcloud version ? " VERSION info "Check if require folders exist" -if [ -d "$FOLDER/nextcloud" ]; then +if [ -d "${FOLDER}/nextcloud" ]; then 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" fi -if [ -d "$FOLDER/www" ]; then +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 +if [ -d "${FOLDER}/data" ]; then info "data/ directory exist, continue" else warning "data/ directory don't exist, creating" - mkdir $FOLDER/data || fatal "Error when creating folder. Exiting" + mkdir ${FOLDER}/data || fatal "Error when creating folder. Exiting" NEW_INSTALLATION=true fi -if [ -d "$FOLDER/config" ]; then +if [ -d "${FOLDER}/config" ]; then info "config/ directory exist, continue" else warning "config/ directory don't exist, creating" - mkdir $FOLDER/config || fatal "Error when creating folder. Exiting" + mkdir ${FOLDER}/config || fatal "Error when creating folder. Exiting" NEW_INSTALLATION=true fi -if [ -d "$FOLDER/apps" ]; then +if [ -d "${FOLDER}/apps" ]; then info "apps/ directory exist, continue" else warning "apps/ directory don't exist, creating" - mkdir $FOLDER/apps || fatal "Error when creating folder. Exiting" + mkdir ${FOLDER}/apps || fatal "Error when creating folder. Exiting" NEW_INSTALLATION=true fi # Download nextcloud -info "Download Nextcloud $VERSION" -wget -q https://download.nextcloud.com/server/releases/nextcloud-$VERSION.zip || fatal "Download failed. Please retry" -if [ ! -f "$FOLDER/nextcloud-$VERSION.zip" ]; then +info "Download Nextcloud ${VERSION}" +wget -q https://download.nextcloud.com/server/releases/nextcloud-${VERSION}.zip || fatal "Download failed. Please retry" +if [ ! -f "${FOLDER}/nextcloud-${VERSION}.zip" ]; then fatal "Download of Nextcloud archive failed. Please retry" fi @@ -92,22 +92,22 @@ if [ ! -f "$FOLDER/nextcloud-$VERSION.zip.sha256" ]; then fi info "Download asc of Nextcloud" -wget -q https://download.nextcloud.com/server/releases/nextcloud-$VERSION.zip.asc || fatal "Download of Nextcloud signature failed. Please retry" -if [ ! -f "$FOLDER/nextcloud-$VERSION.zip.asc" ]; then +wget -q https://download.nextcloud.com/server/releases/nextcloud-${VERSION}.zip.asc || fatal "Download of Nextcloud signature failed. Please retry" +if [ ! -f "${FOLDER}/nextcloud-${VERSION}.zip.asc" ]; then fatal "Download of Nextcloud signature failed. Please retry" fi # Check integrity nextcloud info "Check nextcloud integrity" -sha256sum -c nextcloud-$VERSION.zip.sha256 >/dev/null || fatal "Checksum did not match" -gpg -q --verify nextcloud-$VERSION.zip.asc 2>/dev/null|| fatal "Signature is not good" +sha256sum -c nextcloud-${VERSION}.zip.sha256 >/dev/null || fatal "Checksum did not match" +gpg -q --verify nextcloud-${VERSION}.zip.asc 2>/dev/null|| fatal "Signature is not good" info "Start update" -info "Unzip Nextcloud $VERSION" -unzip -q nextcloud-$VERSION.zip +info "Unzip Nextcloud ${VERSION}" +unzip -q nextcloud-${VERSION}.zip -if [[ $NEW_INSTALLATION == "false" ]]; then +if [[ ${NEW_INSTALLATION} == "false" ]]; then info "Unlink folders that contain the data" unlink www/data unlink www/config @@ -116,24 +116,28 @@ if [[ $NEW_INSTALLATION == "false" ]]; then 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/* + + info "Copying news apps files" fi info "Copying new Nextcloud" +cp -rf nextcloud/apps/* apps/ +rm -rf nextcloud/{config,data,apps} cp -rf nextcloud/* www/ -rm -rf www/{config,data,apps} info "Link folders that contain the data into new installation" -ln -s $FOLDER/data $FOLDER/www/ -ln -s $FOLDER/config $FOLDER/www/ -ln -s $FOLDER/apps $FOLDER/www/ +ln -s ${FOLDER}/data ${FOLDER}/www/ +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 nextcloud-${VERSION}.zip* ../nextcloud/ info "Setting good permission" cd www/ @@ -147,7 +151,7 @@ info "Launch integrity check" php occ check read -n1 -p "Would you like scann all file (recommanded) [y,n]" SCAN -case $SCAN in +case ${SCAN} in y|Y) info "Launch files scan" && php console.php files:scan --all ;; n|N) info "Don't launch files scan" ;; *) echo Please use y or n ;;