forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubernetes.sh
executable file
·63 lines (48 loc) · 1.62 KB
/
kubernetes.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# requires: createrepo reposync wget curl
set -e
set -o pipefail
_here=`dirname $(realpath $0)`
. ${_here}/helpers/apt-download
[ -z "${LOADED_APT_DOWNLOAD}" ] && (echo "failed to load apt-download"; exit 1)
BASE_PATH="${TUNASYNC_WORKING_DIR}"
BASE_URL=${TUNASYNC_UPSTREAM_URL:-"https://packages.cloud.google.com"}
YUM_PATH="${BASE_PATH}/yum/repos"
APT_PATH="${BASE_PATH}/apt"
APT_VERSIONS=(kubernetes-jessie kubernetes-stretch kubernetes-trusty kubernetes-xenial minikube-jessie minikube-trusty)
EL_VERSIONS=(kubernetes-el7-aarch64 kubernetes-el7-armhfp kubernetes-el7-x86_64)
mkdir -p ${YUM_PATH} ${APT_PATH}
# =================== APT repos ===============================
if [[ ! -z ${DRY_RUN:-} ]]; then
export APT_DRY_RUN=1
fi
base_url="${BASE_URL}/apt"
for version in ${APT_VERSIONS[@]}; do
for arch in "amd64" "i386" "arm64" "armhf"; do
echo "=== Syncing $version $arch"
apt-download-binary ${base_url} "$version" "main" "$arch" "${APT_PATH}" || true
done
done
echo "APT finished"
# =================== YUM/DNF repos ==========================
base_url="${BASE_URL}/yum/repos"
cache_dir="/tmp/yum-k8s-cache/"
cfg="/tmp/yum-k8s.conf"
if [[ -z ${DRY_RUN:-} ]]; then
for elver in ${EL_VERSIONS[@]}; do
echo "=== Syncing $elver"
cat << EOF > $cfg
[main]
keepcache=0
[${elver}]
name=${elver}
baseurl=${base_url}/${elver}/
enabled=1
EOF
arch=(${elver//-/ })
arch=${arch[-1]}
reposync -a "$arch" -c "$cfg" -d -p "${YUM_PATH}" -e "$cache_dir"
[[ -d "${YUM_PATH}/${elver}" ]] || mkdir "${YUM_PATH}/${elver}"
createrepo --update -v -c "$cache_dir" -o "${YUM_PATH}/${elver}/" "${YUM_PATH}/${elver}/"
done
fi