Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mirror-clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -euo pipefail

_here=$(dirname "$(realpath "$0")")
mirror_clone="${MIRRORCLONE_BIN:-${_here}/mirror-clone}"

TUNASYNC_MIRRORCLONE_OPTIONS=${TUNASYNC_MIRRORCLONE_OPTIONS:-}
TUNASYNC_MIRRORCLONE_SOURCE=${TUNASYNC_MIRRORCLONE_SOURCE:-}
TUNASYNC_MIRRORCLONE_ARGS=${TUNASYNC_MIRRORCLONE_ARGS:-}

if [ -z "$TUNASYNC_MIRRORCLONE_SOURCE" ]; then
echo "Error: TUNASYNC_MIRRORCLONE_SOURCE is not set" >&2
exit 1
fi

[ ! -d "${TUNASYNC_WORKING_DIR}" ] && mkdir -p "${TUNASYNC_WORKING_DIR}"
cd "${TUNASYNC_WORKING_DIR}"
Comment on lines +17 to +18
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the convention used by other scripts in this repo (chef.sh/cvmfs.sh/termux.sh) — they all dereference TUNASYNC_WORKING_DIR directly and rely on the tunasync framework to set it. Keeping consistent with that.


exec "$mirror_clone" \
--target-type file \
--file-buffer-path "${TUNASYNC_WORKING_DIR}/.tmp" \
--file-base-path "${TUNASYNC_WORKING_DIR}" \
$TUNASYNC_MIRRORCLONE_OPTIONS \
"$TUNASYNC_MIRRORCLONE_SOURCE" \
$TUNASYNC_MIRRORCLONE_ARGS
Comment on lines +24 to +26
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unquoted expansion is intentional: it lets per-mirror configs pass multiple positional flags through TUNASYNC_MIRRORCLONE_OPTIONS / TUNASYNC_MIRRORCLONE_ARGS. Switching to bash arrays would change the public interface (existing tunasync mirror configs would have to be rewritten). Keeping current behavior.

Loading