Skip to content

Commit

Permalink
docker: support for ncp-update-nc
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Jan 17, 2019
1 parent 1dd1bb7 commit d0ca44a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 9 additions & 11 deletions bin/ncp-update-nc
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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"

6 changes: 4 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

[v1.4.0](https://github.com/nextcloud/nextcloudpi/commit/2bd3e67) (2019-01-16) add nc-trusted-domains
[v1.4.1](https://github.com/nextcloud/nextcloudpi/commit/9e0c100) (2019-01-16) docker: support for ncp-update-nc

[v1.3.11](https://github.com/nextcloud/nextcloudpi/commit/84ac075) (2019-01-16) nc-backup: parallel compression
[v1.4.0](https://github.com/nextcloud/nextcloudpi/commit/1dd1bb7) (2019-01-16) add nc-trusted-domains

[v1.3.11 ](https://github.com/nextcloud/nextcloudpi/commit/84ac075) (2019-01-16) nc-backup: parallel compression

[v1.3.10 ](https://github.com/nextcloud/nextcloudpi/commit/2419e57) (2019-01-15) nc-backup: compress in place and exclude previews folder

Expand Down

0 comments on commit d0ca44a

Please sign in to comment.