From 00bbe6f8b4448eef637e6cd486fae1224456726d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 30 Aug 2013 19:01:50 +0200 Subject: [clone_stage4] Extend and refine filterlist and filtering process --- scripts/clone_stage4 | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'scripts') 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." + -- cgit v1.2.3-55-g7522