diff options
author | nachoparker <nacho@ownyourbits.com> | 2019-01-17 05:27:00 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-01-17 05:27:03 +0300 |
commit | d0ca44a6fcf1a5426de27f49fd43891d04d0f223 (patch) | |
tree | 3925af8642a709de932cb67fe200fc834c9050aa /bin/ncp-update-nc | |
parent | 1dd1bb737d18bbdf93f8368da3c7ccd0f879003d (diff) |
docker: support for ncp-update-ncv1.4.1
Diffstat (limited to 'bin/ncp-update-nc')
-rwxr-xr-x | bin/ncp-update-nc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc index 11632603..8d5c8149 100755 --- a/bin/ncp-update-nc +++ b/bin/ncp-update-nc @@ -23,9 +23,8 @@ VER="$1" # pre-checks #################### -[[ -f /.docker-image ]] && { echo "This feature is still not available for docker containers"; exit 1; } - -cd /var/www/ +[[ -f /.docker-image ]] && BASEDIR=/data || BASEDIR=/var/www/ +cd "$BASEDIR" DATADIR="$( grep datadirectory nextcloud/config/config.php | awk '{ print $3 }' | grep -oP "[^']*[^']" | head -1 )" [[ -d /var/www/nextcloud-old ]] && { echo "Nextcloud backup directory found. Interrupted installation?"; exit 1; } [[ -d /var/www/nextcloud ]] || { echo "Nextcloud directory not found" ; exit 1; } @@ -73,7 +72,7 @@ cleanup() { local RET=$? set +eE echo "Clean up..." - rm -rf /var/www/nextcloud.tar.bz2 /var/www/nextcloud-old + rm -rf "$BASEDIR"/nextcloud.tar.bz2 "$BASEDIR"/nextcloud-old trap "" EXIT exit $RET } @@ -111,8 +110,8 @@ rollback_simple() { set +eE trap "" INT TERM HUP ERR echo -e "Abort\nSimple roll back..." - rm -rf /var/www/nextcloud - mv /var/www/nextcloud-old /var/www/nextcloud + rm -rf "$BASEDIR"/nextcloud + mv "$BASEDIR"/nextcloud-old "$BASEDIR"/nextcloud false || cleanup # so cleanup exits with 1 } trap rollback_simple INT TERM HUP ERR @@ -146,7 +145,7 @@ done # copy data if it was at the default location #################### -[[ "$DATADIR" == "/var/www/nextcloud/data" ]] && { +[[ "$DATADIR" == ""$BASEDIR"/nextcloud/data" ]] && { echo "Restore data..." mv -T nextcloud-old/data nextcloud/data } @@ -157,12 +156,12 @@ rollback() { set +eE trap "" INT TERM HUP ERR EXIT echo -e "Abort\nClean up..." - rm -rf /var/www/nextcloud.tar.bz2 /var/www/nextcloud-old + rm -rf /var/www/nextcloud.tar.bz2 "$BASEDIR"/nextcloud-old echo "Rolling back to backup $BKP..." local TMPDATA="$( mktemp -d "/var/www/ncp-data.XXXXXX" )" || { echo "Failed to create temp dir" >&2; exit 1; } - [[ "$DATADIR" == "/var/www/nextcloud/data" ]] && mv -T "$DATADIR" "$TMPDATA" + [[ "$DATADIR" == "$BASEDIR/nextcloud/data" ]] && mv -T "$DATADIR" "$TMPDATA" ncp-restore "$BKP" || { echo "Rollback failed! Data left at $TMPDATA"; exit 1; } - [[ "$DATADIR" == "/var/www/nextcloud/data" ]] && { rm -rf "$DATADIR"; mv -T "$TMPDATA" "$DATADIR"; } + [[ "$DATADIR" == "$BASEDIR/nextcloud/data" ]] && { rm -rf "$DATADIR"; mv -T "$TMPDATA" "$DATADIR"; } rm "$BKP" echo "Rollback successful. Nothing was updated" exit 1 @@ -189,4 +188,3 @@ mv "$BKP" "$DATADIR"/ncp-update-backups chown -R www-data:www-data "$DATADIR"/ncp-update-backups BKP="$DATADIR"/ncp-update-backups/"$( basename "$BKP" )" echo "Backup stored at $BKP" - |