From 741e79a857577f3aff5e219161e4293db050cb3f Mon Sep 17 00:00:00 2001 From: nachoparker Date: Tue, 15 May 2018 08:57:13 +0200 Subject: nc-restore: refuse to restore from /var/www/nextcloud --- changelog.md | 6 ++++-- etc/ncp-config.d/nc-restore.sh | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index c392270d..59108f17 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v0.56.1](https://github.com/nextcloud/nextcloudpi/commit/ef49d0e) (2018-05-15) nc-update-nextcloud: rollback in case of power cut +[v0.56.2](https://github.com/nextcloud/nextcloudpi/commit/550f96a) (2018-05-15) nc-restore: refuse to restore from /var/www/nextcloud -[v0.56.0](https://github.com/nextcloud/nextcloudpi/commit/3c56aa8) (2018-05-15) added nc-autoupdate-nc +[v0.56.1](https://github.com/nextcloud/nextcloudpi/commit/06f1d5c) (2018-05-15) nc-update-nextcloud: rollback in case of power cut + +[v0.56.0 ](https://github.com/nextcloud/nextcloudpi/commit/0248ba3) (2018-05-15) added nc-autoupdate-nc [v0.55.4 ](https://github.com/nextcloud/nextcloudpi/commit/ef88be9) (2018-05-15) nc-autoupdate-ncp: fix wrong user diff --git a/etc/ncp-config.d/nc-restore.sh b/etc/ncp-config.d/nc-restore.sh index b4f99a1a..30fc745c 100644 --- a/etc/ncp-config.d/nc-restore.sh +++ b/etc/ncp-config.d/nc-restore.sh @@ -38,9 +38,12 @@ BACKUPFILE="$1" DBADMIN=ncadmin DBPASSWD="$( grep password /root/.my.cnf | sed 's|password=||' )" -[ $# -eq 0 ] && { echo "missing first argument"; exit 1; } -[ -f "$BACKUPFILE" ] || { echo "$BACKUPFILE not found" ; exit 1; } -[ -d /var/www/nextcloud ] && { echo "INFO: overwriting old instance"; } +DIR="$( cd "$( dirname "$BACKUPFILE" )" &>/dev/null && pwd )" #abspath + +[[ $# -eq 0 ]] && { echo "missing first argument" ; exit 1; } +[[ -f "$BACKUPFILE" ]] || { echo "$BACKUPFILE not found" ; exit 1; } +[[ "$DIR" =~ "/var/www/nextcloud" ]] && { echo "Refusing to restore from /var/www/nextcloud"; exit 1; } +[[ -d /var/www/nextcloud ]] && { echo "INFO: overwriting old instance"; } TMPDIR="$( mktemp -d "$( dirname "$BACKUPFILE" )"/ncp-restore.XXXXXX )" || { echo "Failed to create temp dir" >&2; exit 1; } TMPDIR="$( cd "$TMPDIR" &>/dev/null && pwd )" || { echo "$TMPDIR not found"; exit 1; } #abspath -- cgit v1.2.3