Introduce DOKKU_ROOT and import now in git plugin
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
;;
|
||||
|
||||
@@ -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
|
||||
|
||||
17
plugins/git/backup-import
Executable file
17
plugins/git/backup-import
Executable file
@@ -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 <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -e; set -o pipefail;
|
||||
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
|
||||
EOF
|
||||
chmod +x $PRERECEIVE_HOOK
|
||||
done < $APPS > /dev/null
|
||||
Reference in New Issue
Block a user