summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2013-08-07 17:43:21 +0200
committerJonathan Bauer2013-08-07 17:43:21 +0200
commitd33c93ef6dd3c3905d27e993d8c28c27e003e18b (patch)
tree3c69881aa10ab15dd96ced9428a82eef009d9a73
parentMerge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff)
downloadtm-scripts-d33c93ef6dd3c3905d27e993d8c28c27e003e18b.tar.gz
tm-scripts-d33c93ef6dd3c3905d27e993d8c28c27e003e18b.tar.xz
tm-scripts-d33c93ef6dd3c3905d27e993d8c28c27e003e18b.zip
[clone_stage4] updated scripts to clone stage4. Script can be run from any path now. Its now also possible to clone a local system.
-rw-r--r--data/basic.nocopy25
-rwxr-xr-xscripts/clone_stage450
2 files changed, 48 insertions, 27 deletions
diff --git a/data/basic.nocopy b/data/basic.nocopy
index ea8ce588..7d00bb6d 100644
--- a/data/basic.nocopy
+++ b/data/basic.nocopy
@@ -1,23 +1,26 @@
-/var/run
-/var/log
-/dev
-/proc
-/sys
/boot
+/cdrom
+/dev
/export
-/home/vmuser
+/home
+/lib/modules
/lost+found
/media
/mnt
/opt/openslx
+/proc
+/root
/run
+/srv
+/sys
/tmp
-/root
/usr/src
-/lib/modules
-*tm-scripts*
+/var/log
+/var/run
+/var/www
*~
*.bak
-*.tmp
+*.git*
*.pid
-
+*.tmp
+*tm-scripts*
diff --git a/scripts/clone_stage4 b/scripts/clone_stage4
index 84805062..ab1cce05 100755
--- a/scripts/clone_stage4
+++ b/scripts/clone_stage4
@@ -1,6 +1,14 @@
#!/bin/bash
+#
+# Helper script to generate a stage4 export
+# for a remote machine per rsync.
+#
-. "../helper/logging.inc"
+SELF="$(readlink -f $0)"
+SCRIPTS_DIR="$(dirname "${SELF}")"
+ROOT_DIR="${SCRIPTS_DIR%/*}"
+
+. "${ROOT_DIR}/helper/logging.inc"
MLTK_PID="$$"
@@ -10,24 +18,34 @@ qnd_exit() {
[ $# -ge 1 ] && kill "$1"
}
+[ $# -lt 3 ] && perror "$0 <remote_ip> <stage_to_exclude> <target_dir>"
-[ $# -lt 3 ] && perror "$0 <vorlage> <stage> <target_dir>"
-
-BASEDIR="./server/local_builds/$1"
-BOOTDIR="./server/boot/$1"
-[ ! -d "$BASEDIR" ] && perror "Unknown Vorlage '$1'"
-BASEDIR="$BASEDIR/$2"
-[ ! -d "$BASEDIR" ] && perror "Unknown Stage '$2' for Vorlage '$1'"
-TARGETDIR="$3"
-mkdir -p "$TARGETDIR"
-mkdir -p "$BOOTDIR"
-[ ! -z "$(ls "$TARGETDIR")" ] && perror "Target dir '$TARGETDIR' not empty"
+BASE_DIR="${ROOT_DIR}/server/local_builds/$1"
+BOOT_DIR="${ROOT_DIR}/server/boot/$1"
+[ ! -d "$BASE_DIR" ] && perror "Unknown Vorlage '$1'"
+BASEDIR="${BASE_DIR}/$2"
+[ ! -d "$BASE_DIR" ] && perror "Unknown Stage '$2' for Vorlage '$1'"
+TARGET_DIR="$3"
+mkdir -p "$TARGET_DIR"
+mkdir -p "$BOOT_DIR"
+[ ! -z "$(ls "${TARGET_DIR}")" ] && perror "Target dir '${TARGET_DIR}' not empty"
pinfo "Building rsync exclude-file for building stage 4...."
-cp "data/basic.nocopy" "$BOOTDIR/exclude-stage4"
-find "$BASEDIR" -type f | cut -c $[${#BASEDIR} + 1]- >> "$BOOTDIR/exclude-stage4"
+cp "${ROOT_DIR}/data/basic.nocopy" "${BOOT_DIR}/exclude-stage4"
+
+# this next command lists all files found in BASE_DIR and removed the prefix BASE_DIR
+find "${BASE_DIR}" -type f | cut -c $[${#BASE_DIR} + 1]- >> "${BOOT_DIR}/exclude-stage4"
pinfo "Done."
-pinfo "Cloning via rsync"
-rsync -a --numeric-ids -v --exclude-from="$BOOTDIR/exclude-stage4" -e "ssh -oStrictHostKeyChecking=no" "root@$1:/" "$TARGETDIR" || perror "rsync from 'root@$1:/' to '$TARGETDIR' failed."
+# prepare rsync's options depending on whether the source is local or remote
+RSYNC_OPTS=""
+RSYNC_SOURCE=""
+if [[ "$1" == "local" ]]; then
+ RSYNC_SOURCE="/"
+else
+ RSYNC_SOURCE="root@$1:/"
+ RSYNC_OPTS="-e ssh -oStrictHostKeyChecking=no"
+fi
+pinfo "Cloning via rsync"
+rsync -a --numeric-ids -v --exclude-from="${BOOT_DIR}/exclude-stage4" "${RSYNC_OPTS}" "${RSYNC_SOURCE}" "${TARGET_DIR}" || perror "rsync from '${RSYNC_SOURCE}' to '${TARGET_DIR}' failed."