diff options
author | Simon Rettberg | 2013-08-30 19:01:50 +0200 |
---|---|---|
committer | Jonathan Bauer | 2013-09-30 13:22:03 +0200 |
commit | 2ad4b8f4096096e3e5553f0802891ed7b5d7d15a (patch) | |
tree | b7ca35cff9e48d74c16a2932e7eada33807acf39 /scripts | |
parent | [vbox] conf for Ubuntu 13.04 (diff) | |
download | tm-scripts-2ad4b8f4096096e3e5553f0802891ed7b5d7d15a.tar.gz tm-scripts-2ad4b8f4096096e3e5553f0802891ed7b5d7d15a.tar.xz tm-scripts-2ad4b8f4096096e3e5553f0802891ed7b5d7d15a.zip |
[clone_stage4] Extend and refine filterlist and filtering process
Diffstat (limited to 'scripts')
-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." + |