make lxc-images support LXD/LXC 2.0

This commit is contained in:
Feng Yu 2016-09-22 21:52:20 +08:00
parent 49a6c964e9
commit ec06c94bb9

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# requires: lftp wget # requires: lftp wget jq
BASE_URL="${TUNASYNC_UPSTREAM_URL:-"http://images.linuxcontainers.org/"}" BASE_URL="${TUNASYNC_UPSTREAM_URL:-"http://images.linuxcontainers.org/"}"
@ -16,5 +16,13 @@ function sync_lxc_images() {
sync_lxc_images "${BASE_URL}/images" "${TUNASYNC_WORKING_DIR}/images" sync_lxc_images "${BASE_URL}/images" "${TUNASYNC_WORKING_DIR}/images"
mkdir -p "${TUNASYNC_WORKING_DIR}/meta/1.0" mkdir -p "${TUNASYNC_WORKING_DIR}/meta/1.0"
wget -O "${TUNASYNC_WORKING_DIR}/meta/1.0/index-system" "${BASE_URL}/meta/1.0/index-system" wget -c -T5 -O "${TUNASYNC_WORKING_DIR}/meta/1.0/index-system" "${BASE_URL}/meta/1.0/index-system"
wget -O "${TUNASYNC_WORKING_DIR}/meta/1.0/index-user" "${BASE_URL}/meta/1.0/index-user" wget -c -T5 -O "${TUNASYNC_WORKING_DIR}/meta/1.0/index-user" "${BASE_URL}/meta/1.0/index-user"
mkdir -p "${TUNASYNC_WORKING_DIR}/streams/v1"
wget -c -T5 -O "${TUNASYNC_WORKING_DIR}/streams/v1/index.json" "${BASE_URL}/streams/v1/index.json"
jq -r '.index.images.path' "${TUNASYNC_WORKING_DIR}/streams/v1/index.json" | while read line; do
[ ! -d "$(dirname $line)" ] && mkdir -p "$(dirname $line)"
wget -c -T5 -O "${TUNASYNC_WORKING_DIR}/${line}" "${BASE_URL}/${line}"
done