mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-07-01 07:22:45 +00:00
optimize pref. of lxc-images.sh
This commit is contained in:
parent
08791785e0
commit
cd6f7067b0
@ -12,7 +12,7 @@ function sync_lxc_images() {
|
|||||||
[[ ! -d "$repo_dir" ]] && mkdir -p "$repo_dir"
|
[[ ! -d "$repo_dir" ]] && mkdir -p "$repo_dir"
|
||||||
cd "$repo_dir"
|
cd "$repo_dir"
|
||||||
|
|
||||||
lftp "${repo_url}" -e "mirror --verbose -P 5 --delete --only-newer; bye"
|
lftp "${repo_url}" -e "mirror --verbose -P 5 ; bye"
|
||||||
echo "lftp returns $?"
|
echo "lftp returns $?"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,20 +34,18 @@ done
|
|||||||
|
|
||||||
echo "=== Downloading images ==="
|
echo "=== Downloading images ==="
|
||||||
|
|
||||||
|
sync_lxc_images "${BASE_URL}/images" "${TUNASYNC_WORKING_DIR}/images"
|
||||||
|
|
||||||
images_json="${TUNASYNC_WORKING_DIR}/streams/v1/images.json.work-in-progress"
|
images_json="${TUNASYNC_WORKING_DIR}/streams/v1/images.json.work-in-progress"
|
||||||
[[ -f "$images_json" ]] || exit 1
|
[[ -f "$images_json" ]] || exit 1
|
||||||
jq -r '.products[].versions[].items[].path' "$images_json" > /tmp/filelist.txt
|
jq -r '.products[].versions[].items[].path' "$images_json" > /tmp/filelist.txt
|
||||||
|
|
||||||
#cut -f 6 -d ';' "${TUNASYNC_WORKING_DIR}/meta/1.0/index-system.work-in-progress"
|
|
||||||
cat /tmp/filelist.txt | while read line; do
|
cat /tmp/filelist.txt | while read line; do
|
||||||
# $line looks like 'images/ubuntu/xenial/armhf/default/20200219_07:42/rootfs.tar.xz'
|
# $line looks like 'images/ubuntu/xenial/armhf/default/20200219_07:42/rootfs.tar.xz'
|
||||||
dir="$(dirname $line)"
|
if [[ ! -f "${TUNASYNC_WORKING_DIR}/${line}" ]]; then
|
||||||
if [[ "$dir" = "$last_dir" ]]; then
|
echo "Error: ${TUNASYNC_WORKING_DIR}/${line} vanished"
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
last_dir="$dir"
|
|
||||||
echo "=== Syncing $dir ==="
|
|
||||||
sync_lxc_images "${BASE_URL}/${dir}" "${TUNASYNC_WORKING_DIR}/${dir}"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "=== Replacing /meta/1.0 ==="
|
echo "=== Replacing /meta/1.0 ==="
|
||||||
|
Loading…
x
Reference in New Issue
Block a user