summaryrefslogblamecommitdiffstats
path: root/scripts/clone_stage4
blob: 84805062880855c8ac0591cf07c3cf521915c7fd (plain) (tree)
1
2
3

           
                         





























                                                                                                                                                                                          
#!/bin/bash

. "../helper/logging.inc"

MLTK_PID="$$"

qnd_exit() {
	unset_quiet
	kill "$MLTK_PID"
	[ $# -ge 1 ] && kill "$1"
}


[ $# -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"

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"
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."