#!/bin/sh

ALPINE_VER=$(cat /etc/alpine-release 2>/dev/null | cut -d. -f1,2)

mkdir -p /etc/apk/repositories.d

cat > /etc/apk/repositories.d/alt-python-els.list <<EOF
https://repo.alt.tuxcare.com/alt-python-els/\$TOKEN/apk/alpine/${ALPINE_VER}/stable
EOF

# Gradual-rollout slots els-alt-1..6, mirroring the rpm rollout repos (ELS-2641).
# All six slot lines stay active: the rollout host serves only the slot this
# client is assigned to and redirects the others to a signed empty index, so apk
# reports no error for them. The slot-N-bypass entries are the opt-in immediate
# update -- uncomment one, then run apk update. Unlike the stable URL above
# there is no token: rollout.alt.tuxcare.com takes no credentials.
cat > /etc/apk/repositories.d/alt-python-els-rollout.list <<EOF
https://rollout.alt.tuxcare.com/alt-python-els/slot-1/apk/alpine/${ALPINE_VER}
https://rollout.alt.tuxcare.com/alt-python-els/slot-2/apk/alpine/${ALPINE_VER}
https://rollout.alt.tuxcare.com/alt-python-els/slot-3/apk/alpine/${ALPINE_VER}
https://rollout.alt.tuxcare.com/alt-python-els/slot-4/apk/alpine/${ALPINE_VER}
https://rollout.alt.tuxcare.com/alt-python-els/slot-5/apk/alpine/${ALPINE_VER}
https://rollout.alt.tuxcare.com/alt-python-els/slot-6/apk/alpine/${ALPINE_VER}
# Immediate update, bypassing the gradual rollout: uncomment one line below.
# https://rollout.alt.tuxcare.com/alt-python-els/slot-1-bypass/apk/alpine/${ALPINE_VER}
# https://rollout.alt.tuxcare.com/alt-python-els/slot-2-bypass/apk/alpine/${ALPINE_VER}
# https://rollout.alt.tuxcare.com/alt-python-els/slot-3-bypass/apk/alpine/${ALPINE_VER}
# https://rollout.alt.tuxcare.com/alt-python-els/slot-4-bypass/apk/alpine/${ALPINE_VER}
# https://rollout.alt.tuxcare.com/alt-python-els/slot-5-bypass/apk/alpine/${ALPINE_VER}
# https://rollout.alt.tuxcare.com/alt-python-els/slot-6-bypass/apk/alpine/${ALPINE_VER}
EOF

exit 0
