forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlxc-images.sh
executable file
·29 lines (21 loc) · 991 Bytes
/
lxc-images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# requires: lftp wget jq
BASE_URL="${TUNASYNC_UPSTREAM_URL:-"http://images.linuxcontainers.org/"}"
function sync_lxc_images() {
repo_url="$1"
repo_dir="$2"
[ ! -d "$repo_dir" ] && mkdir -p "$repo_dir"
cd $repo_dir
lftp "${repo_url}/" -e "mirror --verbose -P 5 --delete --only-newer; bye"
}
sync_lxc_images "${BASE_URL}/images" "${TUNASYNC_WORKING_DIR}/images"
mkdir -p "${TUNASYNC_WORKING_DIR}/meta/1.0"
for i in index-system index-system.asc index-user index-user.asc; do
wget -O "${TUNASYNC_WORKING_DIR}/meta/1.0/"$i "${BASE_URL}/meta/1.0/"$i
done
mkdir -p "${TUNASYNC_WORKING_DIR}/streams/v1"
wget -O "${TUNASYNC_WORKING_DIR}/streams/v1/index.json" "${BASE_URL}/streams/v1/index.json"
jq -r '.index[].path' "${TUNASYNC_WORKING_DIR}/streams/v1/index.json" | while read line; do
[ ! -d "${TUNASYNC_WORKING_DIR}/$(dirname $line)" ] && mkdir -p "${TUNASYNC_WORKING_DIR}/$(dirname $line)"
wget -O "${TUNASYNC_WORKING_DIR}/${line}" "${BASE_URL}/${line}"
done