From 2219044114c9b8ca0a046a90c3dc52f5e3f20559 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 14 Nov 2013 23:51:35 +0100 Subject: [PATCH] Introduce DOKKU_ROOT and import now in git plugin --- plugins/00_dokku-standard/backup-export | 1 + plugins/00_dokku-standard/backup-import | 1 + plugins/backup/commands | 14 +++++++------- plugins/config/backup-import | 2 +- plugins/git/backup-import | 17 +++++++++++++++++ 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100755 plugins/git/backup-import diff --git a/plugins/00_dokku-standard/backup-export b/plugins/00_dokku-standard/backup-export index 58d4ac43c..102ef082c 100755 --- a/plugins/00_dokku-standard/backup-export +++ b/plugins/00_dokku-standard/backup-export @@ -3,6 +3,7 @@ VERSION="$1" BASE_DIR="$2" cat; +[[ -f $BASE_DIR/.sshcommand ]] && echo "$BASE_DIR/.sshcommand" [[ -f $BASE_DIR/.ssh/authorized_keys ]] && echo "$BASE_DIR/.ssh/authorized_keys" [[ -f $BASE_DIR/HOSTNAME ]] && echo "$BASE_DIR/HOSTNAME" [[ -f $BASE_DIR/VHOST ]] && echo "$BASE_DIR/VHOST" diff --git a/plugins/00_dokku-standard/backup-import b/plugins/00_dokku-standard/backup-import index 2fa31c13f..a3f691d9d 100755 --- a/plugins/00_dokku-standard/backup-import +++ b/plugins/00_dokku-standard/backup-import @@ -3,6 +3,7 @@ VERSION="$1" IMPORT_DIR="$2" TARGET_DIR="$3" +[[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then mkdir $TARGET_DIR/.ssh mv $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys diff --git a/plugins/backup/commands b/plugins/backup/commands index 312e5cea6..635b44a8e 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -3,7 +3,7 @@ CURRENT_BACKUP_VERSION=1 set -e; case "$1" in backup:export) OUTPUT_FILE="$2" - BACKUP_DIR=/home/git + BACKUP_DIR="$DOKKU_ROOT" BACKUP_TMP_DIR=$(mktemp -d) BACKUP_TMP_FILE="$BACKUP_TMP_DIR/backup.tar" @@ -11,7 +11,7 @@ set -e; case "$1" in pluginhook backup-export 1 $BACKUP_DIR | tar -cf $BACKUP_TMP_FILE --files-from - pushd $BACKUP_DIR > /dev/null - ls -d */ > "$BACKUP_TMP_DIR/.dokku_backup_apps" + ls -d */ | grep -oE '[^/]+' > "$BACKUP_TMP_DIR/.dokku_backup_apps" popd > /dev/null # we want to insert the files in the root of the tar @@ -50,14 +50,14 @@ set -e; case "$1" in exit 1 fi - BACKUP_ROOT="$BACKUP_TMP_DIR/home/git" - TARGET_DIR="/home/git" + BACKUP_ROOT="$BACKUP_TMP_DIR""$DOKKU_ROOT" + TARGET_DIR="$DOKKU_ROOT" - # create all the app repositories - while read app; do git init --bare "$TARGET_DIR/$app"; done < $BACKUP_TMP_DIR/.dokku_backup_apps > /dev/null + # create all the app directories + while read app; do mkdir "$TARGET_DIR/$app"; done < $BACKUP_TMP_DIR/.dokku_backup_apps > /dev/null # have the plugins import their stuff - pluginhook backup-import $VERSION "$BACKUP_ROOT" $TARGET_DIR + pluginhook backup-import $VERSION "$BACKUP_ROOT" $TARGET_DIR "$BACKUP_TMP_DIR/.dokku_backup_apps" rm -rf $BACKUP_TMP_DIR ;; diff --git a/plugins/config/backup-import b/plugins/config/backup-import index c3b20e58a..7face8b95 100755 --- a/plugins/config/backup-import +++ b/plugins/config/backup-import @@ -5,5 +5,5 @@ TARGET_DIR="$3" cd $IMPORT_DIR for file in `find . -regex ".*/ENV"`; do - cp $file $TARGET_DIR$file + cp $file "$TARGET_DIR/$file" done diff --git a/plugins/git/backup-import b/plugins/git/backup-import new file mode 100755 index 000000000..b7b0505b6 --- /dev/null +++ b/plugins/git/backup-import @@ -0,0 +1,17 @@ +#!/bin/bash +VERSION="$1" +IMPORT_DIR="$2" +TARGET_DIR="$3" +APPS="$4" + +while read APP; do + APP_PATH="$TARGET_DIR/$APP"; + git init --bare $APP_PATH > /dev/null + PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" + cat > $PRERECEIVE_HOOK < /dev/null