diff options
| author | Simon Rettberg | 2013-09-02 15:57:59 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2013-09-02 15:57:59 +0200 |
| commit | 2505b3c0d9937f96bdf2f2bd290cd5c437ed0894 (patch) | |
| tree | a6e66e1076830f808119329e2beaea5a0d348067 /scripts/clone_stage4 | |
| parent | [helper/useradd] Make sure /etc/shadow has group shadow (diff) | |
| parent | [vbox] Readme file with notes on pathced scripts (diff) | |
| download | tm-scripts-2505b3c0d9937f96bdf2f2bd290cd5c437ed0894.tar.gz tm-scripts-2505b3c0d9937f96bdf2f2bd290cd5c437ed0894.tar.xz tm-scripts-2505b3c0d9937f96bdf2f2bd290cd5c437ed0894.zip | |
Merge branch 'master' of simonslx:openslx-ng/tm-scripts
Diffstat (limited to 'scripts/clone_stage4')
| -rwxr-xr-x | scripts/clone_stage4 | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/clone_stage4 b/scripts/clone_stage4 index ad468f4f..e24fd416 100755 --- a/scripts/clone_stage4 +++ b/scripts/clone_stage4 @@ -29,12 +29,29 @@ TARGET_DIR="$3" mkdir -p "$TARGET_DIR" mkdir -p "$BOOT_DIR" +EXCLUDE="$BOOT_DIR/exclude-stage4" +INCLUDE="$BOOT_DIR/include-stage4" + pinfo "Building rsync exclude-file for building stage 4...." -cp "${ROOT_DIR}/data/basic.nocopy" "${BOOT_DIR}/exclude-stage4" +echo "## Exclude file for stage4 of $1" > "$EXCLUDE" +echo "## Include file for stage4 of $1" > "$INCLUDE" +for FILE in $(find "$ROOT_DIR"/server/blacklists/*/ -type f); do + echo "## From $FILE" >> "$EXCLUDE" + echo "## From $FILE" >> "$INCLUDE" + grep '^-' "$FILE" >> "$EXCLUDE" + grep '^+' "$FILE" >> "$INCLUDE" +done + +echo "## From cloned $2 of $1" >> "$EXCLUDE" +# this next command lists all files found in BASE_DIR and removes the prefix BASE_DIR +IFS=$'\n' +for FILE in $(find "${BASE_DIR}" -type f | cut -c $[${#BASE_DIR} + 1]-); do + echo "- $FILE" >> "$EXCLUDE" +done +unset IFS -# 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." +[ "y$UID" == "y0" ] || perror "You're not root. Cannot continue with rsync." # prepare rsync's options depending on whether the source is local or remote RSYNC_OPTS="" @@ -47,4 +64,5 @@ else fi pinfo "Cloning via rsync" -rsync -a --delete --numeric-ids -v --exclude-from="${BOOT_DIR}/exclude-stage4" "${RSYNC_OPTS}" "${RSYNC_SOURCE}" "${TARGET_DIR}" || perror "rsync from '${RSYNC_SOURCE}' to '${TARGET_DIR}' failed." +cat "$INCLUDE" "$EXCLUDE" | rsync -a --delete --delete-excluded --numeric-ids -v --exclude-from=- "${RSYNC_OPTS}" "${RSYNC_SOURCE}" "${TARGET_DIR}" || perror "rsync from '${RSYNC_SOURCE}' to '${TARGET_DIR}' failed." + |
