Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/build-docker-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ env:
# DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD is required for docker image push, they should be set in CI secrets.
DOCKER_REGISTRY_USERNAME: ${{ vars.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# used to sync image to mirror registry
DOCKER_MIRROR_REGISTRY_USERNAME: ${{ vars.DOCKER_MIRROR_REGISTRY_USERNAME }}
DOCKER_MIRROR_REGISTRY_PASSWORD: ${{ secrets.DOCKER_MIRROR_REGISTRY_PASSWORD }}
CI_PROJECT_NAME: ${{ vars.CI_PROJECT_NAME || 'LabNow/lab-foundation' }}

jobs:
Expand Down Expand Up @@ -56,10 +53,11 @@ jobs:
- env:
AUTH_FILE_CONTENT: ${{ secrets.AUTH_FILE_CONTENT }}
DOCKER_MIRROR_REGISTRY: ${{ vars.DOCKER_MIRROR_REGISTRY }}
DOCKER_MIRROR_TARGETS: ${{ vars.DOCKER_MIRROR_TARGETS }}
run: |
source ./tool.sh
printf '%s' "$AUTH_FILE_CONTENT" > .github/workflows/auth.json && ls -alh ./.github/workflows
printenv | grep -v 'PATH' > /tmp/docker.env && echo "REGISTRY_URL=${REGISTRY_DST}" >> /tmp/docker.env
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp ${IMG_PREFIX_DST:-labnow}/docker-kit \
python /opt/utils/image-syncer/run_jobs.py --auth-file=/tmp/.github/workflows/auth.json \
--workflow-file=".github/workflows/build-docker-db.yml"
sh /opt/utils/script-sync-image.sh --file-auth=/tmp/.github/workflows/auth.json \
--file-workflow=".github/workflows/build-docker-db.yml"
8 changes: 3 additions & 5 deletions .github/workflows/build-docker-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ env:
# DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD is required for docker image push, they should be set in CI secrets.
DOCKER_REGISTRY_USERNAME: ${{ vars.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# used to sync image to mirror registry
DOCKER_MIRROR_REGISTRY_USERNAME: ${{ vars.DOCKER_MIRROR_REGISTRY_USERNAME }}
DOCKER_MIRROR_REGISTRY_PASSWORD: ${{ secrets.DOCKER_MIRROR_REGISTRY_PASSWORD }}
CI_PROJECT_NAME: ${{ vars.CI_PROJECT_NAME || 'LabNow/lab-foundation' }}

jobs:
Expand Down Expand Up @@ -161,10 +158,11 @@ jobs:
- env:
AUTH_FILE_CONTENT: ${{ secrets.AUTH_FILE_CONTENT }}
DOCKER_MIRROR_REGISTRY: ${{ vars.DOCKER_MIRROR_REGISTRY }}
DOCKER_MIRROR_TARGETS: ${{ vars.DOCKER_MIRROR_TARGETS }}
run: |
source ./tool.sh
printf '%s' "$AUTH_FILE_CONTENT" > .github/workflows/auth.json && ls -alh ./.github/workflows
printenv | grep -v 'PATH' > /tmp/docker.env && echo "REGISTRY_URL=${REGISTRY_DST}" >> /tmp/docker.env
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp ${IMG_PREFIX_DST:-labnow}/docker-kit \
python /opt/utils/image-syncer/run_jobs.py --auth-file=/tmp/.github/workflows/auth.json \
--workflow-file=".github/workflows/build-docker-gpu.yml"
sh /opt/utils/script-sync-image.sh --file-auth=/tmp/.github/workflows/auth.json \
--file-workflow=".github/workflows/build-docker-gpu.yml"
9 changes: 4 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ env:
# DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD is required for docker image push, they should be set in CI secrets.
DOCKER_REGISTRY_USERNAME: ${{ vars.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# used to sync image to mirror registry
DOCKER_MIRROR_REGISTRY_USERNAME: ${{ vars.DOCKER_MIRROR_REGISTRY_USERNAME }}
DOCKER_MIRROR_REGISTRY_PASSWORD: ${{ secrets.DOCKER_MIRROR_REGISTRY_PASSWORD }}
CI_PROJECT_NAME: ${{ vars.CI_PROJECT_NAME || 'LabNow/lab-foundation' }}

jobs:
Expand Down Expand Up @@ -228,13 +225,14 @@ jobs:
- env:
AUTH_FILE_CONTENT: ${{ secrets.AUTH_FILE_CONTENT }}
DOCKER_MIRROR_REGISTRY: ${{ vars.DOCKER_MIRROR_REGISTRY }}
DOCKER_MIRROR_TARGETS: ${{ vars.DOCKER_MIRROR_TARGETS }}
run: |
source ./tool.sh && build_image docker-kit latest docker_docker_kit/docker-kit.Dockerfile && push_image docker-kit
echo "jobs: { job-docker_kit: { name: 'docker-kit' } }" | tee ".github/workflows/build-docker.yml" > /dev/null
printf '%s' "$AUTH_FILE_CONTENT" > .github/workflows/auth.json && ls -alh ./.github/workflows
printenv | grep -v 'PATH' > /tmp/docker.env && echo "REGISTRY_URL=${REGISTRY_DST}" >> /tmp/docker.env
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp ${IMG_PREFIX_DST:-labnow}/docker-kit \
python /opt/utils/image-syncer/run_jobs.py --auth-file=/tmp/.github/workflows/auth.json
script-sync-image.sh --file-auth=/tmp/.github/workflows/auth.json

## Sync all images in this build (listed by "names") to mirror registry.
job-sync-images:
Expand All @@ -245,9 +243,10 @@ jobs:
- env:
AUTH_FILE_CONTENT: ${{ secrets.AUTH_FILE_CONTENT }}
DOCKER_MIRROR_REGISTRY: ${{ vars.DOCKER_MIRROR_REGISTRY }}
DOCKER_MIRROR_TARGETS: ${{ vars.DOCKER_MIRROR_TARGETS }}
run: |
source ./tool.sh
printf '%s' "$AUTH_FILE_CONTENT" > .github/workflows/auth.json && ls -alh ./.github/workflows
printenv | grep -v 'PATH' > /tmp/docker.env && echo "REGISTRY_URL=${REGISTRY_DST}" >> /tmp/docker.env
docker run --rm --env-file /tmp/docker.env -v $(pwd):/tmp -w /tmp ${IMG_PREFIX_DST:-labnow}/docker-kit \
python /opt/utils/image-syncer/run_jobs.py --auth-file=/tmp/.github/workflows/auth.json
script-sync-image.sh --file-auth=/tmp/.github/workflows/auth.json
33 changes: 17 additions & 16 deletions docker_atom/work/localize/run-config-mirror-aliyun-pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ set -ex

echo "Setup mirror config for Aliyun Public Cloud..."

export TZ=${TZ:="Asia/Shanghai"}
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
export TZ="${TZ:-Asia/Shanghai}"
sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null
echo "Setup timezone, current date: $(date)"

eval "export $(cat /etc/os-release | grep ID=)" && export OS_ID=${ID} && echo "Found ${ID} system, setting mirror for ${ID}"
OS_ID=$(sed -n 's/^ID=//p' /etc/os-release | tr -d '"')
echo "Found ${OS_ID} system, setting mirror for ${OS_ID}"

FILE_DEB=$([ -f /etc/apt/sources.list.d/${OS_ID}.sources ] && echo /etc/apt/sources.list.d/${OS_ID}.sources || echo /etc/apt/sources.list )
if [ -f $FILE_DEB ]; then
sed -i 's|mirrors.*.com/ubuntu|mirrors.aliyun.com/ubuntu|' $FILE_DEB
sed -i 's|archive.ubuntu.com/ubuntu|mirrors.aliyun.com/ubuntu|' $FILE_DEB
sed -i 's|security.ubuntu.com/ubuntu|mirrors.aliyun.com/ubuntu|' $FILE_DEB
sed -i 's|deb.debian.org/debian|mirrors.aliyun.com/debian|' $FILE_DEB
FILE_DEB=$([ -f "/etc/apt/sources.list.d/${OS_ID}.sources" ] && echo "/etc/apt/sources.list.d/${OS_ID}.sources" || echo /etc/apt/sources.list)
if [ -f "$FILE_DEB" ]; then
sudo sed -i 's|mirrors.*.com/ubuntu|mirrors.aliyun.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|archive.ubuntu.com/ubuntu|mirrors.aliyun.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|security.ubuntu.com/ubuntu|mirrors.aliyun.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|deb.debian.org/debian|mirrors.aliyun.com/debian|' "$FILE_DEB"
echo "Finished setting ubuntu/debian mirror"
fi

[ -f /etc/apt/sources.list.d/pgdg.list ] && sed -i 's|apt.postgresql.org/pub|mirrors.aliyun.com/postgresql|' /etc/apt/sources.list.d/pgdg.list
[ -f /etc/apt/sources.list.d/pgdg.list ] && sudo sed -i 's|apt.postgresql.org/pub|mirrors.aliyun.com/postgresql|' /etc/apt/sources.list.d/pgdg.list

if [ -f "$(which python)" ] ; then
if command -v python >/dev/null 2>&1 ; then
echo "Found python, setting pypi source in /etc/pip.conf"
cat >/etc/pip.conf <<EOF
sudo tee /etc/pip.conf >/dev/null <<EOF
[global]
progress_bar=off
root-user-action=ignore
Expand All @@ -35,22 +36,22 @@ EOF
fi

for cmd in npm pnpm yarn bun; do
if [ -f "$(which $cmd)" ] ; then
if command -v "$cmd" >/dev/null 2>&1 ; then
echo "Found $cmd, setting mirror"
"$cmd" config set registry https://registry.npmmirror.com
"$cmd" config list
echo
fi
done

if [ -f "$(which go)" ] ; then
if command -v go >/dev/null 2>&1 ; then
echo "Found golang, setting GOPROXY"
export GOPROXY=https://mirrors.aliyun.com/goproxy/
go env | grep 'PROXY'
fi

if [ -f "$(which R)" ] ; then
if command -v R >/dev/null 2>&1 ; then
echo "Found R, setting CRAN mirror"
echo "options(repos=structure(c(CRAN=\"https://mirrors.aliyun.com/CRAN/\")))" >> /etc/R/Rprofile.site
echo "options(repos=structure(c(CRAN=\"https://mirrors.aliyun.com/CRAN/\")))" | sudo tee -a /etc/R/Rprofile.site >/dev/null
R -e "options('repos');"
fi
33 changes: 17 additions & 16 deletions docker_atom/work/localize/run-config-mirror-aliyun-vpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ set -ex

echo "Setup mirror config for Aliyun Cloud VPC Environment..."

export TZ=${TZ:="Asia/Shanghai"}
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
export TZ="${TZ:-Asia/Shanghai}"
sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null
echo "Setup timezone, current date: $(date)"

eval "export $(cat /etc/os-release | grep ID=)" && export OS_ID=${ID} && echo "Found ${ID} system, setting mirror for ${ID}"
OS_ID=$(sed -n 's/^ID=//p' /etc/os-release | tr -d '"')
echo "Found ${OS_ID} system, setting mirror for ${OS_ID}"

FILE_DEB=$([ -f /etc/apt/sources.list.d/${OS_ID}.sources ] && echo /etc/apt/sources.list.d/${OS_ID}.sources || echo /etc/apt/sources.list )
if [ -f $FILE_DEB ]; then
sed -i 's|mirrors.*.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' $FILE_DEB
sed -i 's|archive.ubuntu.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' $FILE_DEB
sed -i 's|security.ubuntu.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' $FILE_DEB
sed -i 's|deb.debian.org/debian|mirrors.cloud.aliyuncs.com/debian|' $FILE_DEB
FILE_DEB=$([ -f "/etc/apt/sources.list.d/${OS_ID}.sources" ] && echo "/etc/apt/sources.list.d/${OS_ID}.sources" || echo /etc/apt/sources.list)
if [ -f "$FILE_DEB" ]; then
sudo sed -i 's|mirrors.*.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|archive.ubuntu.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|security.ubuntu.com/ubuntu|mirrors.cloud.aliyuncs.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|deb.debian.org/debian|mirrors.cloud.aliyuncs.com/debian|' "$FILE_DEB"
echo "Finished setting ubuntu/debian mirror"
fi

[ -f /etc/apt/sources.list.d/pgdg.list ] && sed -i 's|apt.postgresql.org/pub|mirrors.cloud.aliyuncs.com/postgresql|' /etc/apt/sources.list.d/pgdg.list
[ -f /etc/apt/sources.list.d/pgdg.list ] && sudo sed -i 's|apt.postgresql.org/pub|mirrors.cloud.aliyuncs.com/postgresql|' /etc/apt/sources.list.d/pgdg.list

if [ -f "$(which python)" ] ; then
if command -v python >/dev/null 2>&1 ; then
echo "Found python, setting pypi source in /etc/pip.conf"
cat >/etc/pip.conf <<EOF
sudo tee /etc/pip.conf >/dev/null <<EOF
[global]
progress_bar=off
root-user-action=ignore
Expand All @@ -35,22 +36,22 @@ EOF
fi

for cmd in npm pnpm yarn bun; do
if [ -f "$(which $cmd)" ] ; then
if command -v "$cmd" >/dev/null 2>&1 ; then
echo "Found $cmd, setting mirror"
"$cmd" config set registry https://registry.npmmirror.com
"$cmd" config list
echo
fi
done

if [ -f "$(which go)" ] ; then
if command -v go >/dev/null 2>&1 ; then
echo "Found golang, setting GOPROXY"
export GOPROXY=https://mirrors.cloud.aliyuncs.com/goproxy/
go env | grep 'PROXY'
fi

if [ -f "$(which R)" ] ; then
if command -v R >/dev/null 2>&1 ; then
echo "Found R, setting CRAN mirror"
echo "options(repos=structure(c(CRAN=\"http://mirrors.cloud.aliyuncs.com/CRAN/\")))" >> /etc/R/Rprofile.site
echo "options(repos=structure(c(CRAN=\"http://mirrors.cloud.aliyuncs.com/CRAN/\")))" | sudo tee -a /etc/R/Rprofile.site >/dev/null
R -e "options('repos');"
fi
31 changes: 16 additions & 15 deletions docker_atom/work/localize/run-config-mirror-cernet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ set -ex

echo "Setup mirror config for CERNET..."

export TZ=${TZ:="Asia/Shanghai"}
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
export TZ="${TZ:-Asia/Shanghai}"
sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null
echo "Setup timezone, current date: $(date)"

eval "export $(cat /etc/os-release | grep ID=)" && export OS_ID=${ID} && echo "Found ${ID} system, setting mirror for ${ID}"
OS_ID=$(sed -n 's/^ID=//p' /etc/os-release | tr -d '"')
echo "Found ${OS_ID} system, setting mirror for ${OS_ID}"

FILE_DEB=$([ -f /etc/apt/sources.list.d/${OS_ID}.sources ] && echo /etc/apt/sources.list.d/${OS_ID}.sources || echo /etc/apt/sources.list)
FILE_DEB=$([ -f "/etc/apt/sources.list.d/${OS_ID}.sources" ] && echo "/etc/apt/sources.list.d/${OS_ID}.sources" || echo /etc/apt/sources.list)
if [ -f "$FILE_DEB" ]; then
sed -i 's|mirrors.*.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' $FILE_DEB
sed -i 's|archive.ubuntu.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' $FILE_DEB
sed -i 's|security.ubuntu.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' $FILE_DEB
sed -i 's|deb.debian.org/debian|mirrors.cernet.edu.cn/debian|g' $FILE_DEB
sudo sed -i 's|mirrors.*.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' "$FILE_DEB"
sudo sed -i 's|archive.ubuntu.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' "$FILE_DEB"
sudo sed -i 's|security.ubuntu.com/ubuntu|mirrors.cernet.edu.cn/ubuntu|g' "$FILE_DEB"
sudo sed -i 's|deb.debian.org/debian|mirrors.cernet.edu.cn/debian|g' "$FILE_DEB"
echo "Finished setting Ubuntu/Debian mirror"
fi

[ -f /etc/apt/sources.list.d/pgdg.list ] && sed -i 's|apt.postgresql.org/pub|mirrors.cernet.edu.cn/postgresql|' /etc/apt/sources.list.d/pgdg.list
[ -f /etc/apt/sources.list.d/pgdg.list ] && sudo sed -i 's|apt.postgresql.org/pub|mirrors.cernet.edu.cn/postgresql|' /etc/apt/sources.list.d/pgdg.list

if [ -f "$(which python)" ] ; then
if command -v python >/dev/null 2>&1 ; then
echo "Found python, setting pypi source in /etc/pip.conf"
cat >/etc/pip.conf <<EOF
sudo tee /etc/pip.conf >/dev/null <<EOF
[global]
progress_bar=off
root-user-action=ignore
Expand All @@ -35,22 +36,22 @@ EOF
fi

for cmd in npm pnpm yarn bun; do
if [ -f "$(which $cmd)" ] ; then
if command -v "$cmd" >/dev/null 2>&1 ; then
echo "Found $cmd, setting mirror"
"$cmd" config set registry https://registry.npmmirror.com
"$cmd" config list
echo
fi
done

if [ -f "$(which go)" ] ; then
if command -v go >/dev/null 2>&1 ; then
echo "Found golang, setting GOPROXY"
export GOPROXY=https://mirrors.aliyun.com/goproxy/
go env | grep 'PROXY'
fi

if [ -f "$(which R)" ] ; then
if command -v R >/dev/null 2>&1 ; then
echo "Found R, setting CRAN mirror"
echo 'options(repos=structure(c(CRAN="https://mirrors.cernet.edu.cn/CRAN/")))' >> /etc/R/Rprofile.site
echo 'options(repos=structure(c(CRAN="https://mirrors.cernet.edu.cn/CRAN/")))' | sudo tee -a /etc/R/Rprofile.site >/dev/null
R -e "options('repos');"
fi
12 changes: 6 additions & 6 deletions docker_atom/work/localize/run-config-mirror-default.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#! /bin/sh
set -ex

export TZ=${TZ:="Asia/Shanghai"}
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
export TZ="${TZ:-Asia/Shanghai}"
sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null
echo "Setup timezone, current date: $(date)"

if [ -f /etc/apt/sources.list ] ; then
echo "Found Ubuntu/debian system, using default ubuntu/debian mirror"
fi

if [ -f "$(which python)" ] ; then
if command -v python >/dev/null 2>&1 ; then
echo "Found python, using default pypi source in /etc/pip.conf"
pip config list
fi

if [ -f "$(which npm)" ] ; then
if command -v npm >/dev/null 2>&1 ; then
echo "Found npm, using default npm mirror"
npm config list
fi

if [ -f "$(which go)" ] ; then
if command -v go >/dev/null 2>&1 ; then
echo "Found golang, getting GO env:"
go env | sort
fi

if [ -f "$(which R)" ] ; then
if command -v R >/dev/null 2>&1 ; then
echo "Found R, getting CRAN mirror"
R -e "options('repos');"
fi
33 changes: 17 additions & 16 deletions docker_atom/work/localize/run-config-mirror-tencent-pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ set -ex

echo "Setup mirror config for Tencent Cloud VPC Environment..."

export TZ=${TZ:="Asia/Shanghai"}
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
export TZ="${TZ:-Asia/Shanghai}"
sudo ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" | sudo tee /etc/timezone >/dev/null
echo "Setup timezone, current date: $(date)"

eval "export $(cat /etc/os-release | grep ID=)" && export OS_ID=${ID} && echo "Found ${ID} system, setting mirror for ${ID}"
OS_ID=$(sed -n 's/^ID=//p' /etc/os-release | tr -d '"')
echo "Found ${OS_ID} system, setting mirror for ${OS_ID}"

FILE_DEB=$([ -f /etc/apt/sources.list.d/${OS_ID}.sources ] && echo /etc/apt/sources.list.d/${OS_ID}.sources || echo /etc/apt/sources.list )
if [ -f $FILE_DEB ]; then
sed -i 's|mirrors.*.com/ubuntu|mirrors.tencent.com/ubuntu|' $FILE_DEB
sed -i 's|archive.ubuntu.com/ubuntu|mirrors.tencent.com/ubuntu|' $FILE_DEB
sed -i 's|security.ubuntu.com/ubuntu|mirrors.tencent.com/ubuntu|' $FILE_DEB
sed -i 's|deb.debian.org/debian|mirrors.tencent.com/debian|' $FILE_DEB
FILE_DEB=$([ -f "/etc/apt/sources.list.d/${OS_ID}.sources" ] && echo "/etc/apt/sources.list.d/${OS_ID}.sources" || echo /etc/apt/sources.list)
if [ -f "$FILE_DEB" ]; then
sudo sed -i 's|mirrors.*.com/ubuntu|mirrors.tencent.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|archive.ubuntu.com/ubuntu|mirrors.tencent.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|security.ubuntu.com/ubuntu|mirrors.tencent.com/ubuntu|' "$FILE_DEB"
sudo sed -i 's|deb.debian.org/debian|mirrors.tencent.com/debian|' "$FILE_DEB"
echo "Finished setting ubuntu/debian mirror"
fi

[ -f /etc/apt/sources.list.d/pgdg.list ] && sed -i 's|apt.postgresql.org/pub|mirrors.tencent.com/postgresql|' /etc/apt/sources.list.d/pgdg.list
[ -f /etc/apt/sources.list.d/pgdg.list ] && sudo sed -i 's|apt.postgresql.org/pub|mirrors.tencent.com/postgresql|' /etc/apt/sources.list.d/pgdg.list

if [ -f "$(which python)" ] ; then
if command -v python >/dev/null 2>&1 ; then
echo "Found python, setting pypi source in /etc/pip.conf"
cat >/etc/pip.conf <<EOF
sudo tee /etc/pip.conf >/dev/null <<EOF
[global]
progress_bar=off
root-user-action=ignore
Expand All @@ -35,22 +36,22 @@ EOF
fi

for cmd in npm pnpm yarn bun; do
if [ -f "$(which $cmd)" ] ; then
if command -v "$cmd" >/dev/null 2>&1 ; then
echo "Found $cmd, setting mirror"
"$cmd" config set registry https://registry.npmmirror.com
"$cmd" config list
echo
fi
done

if [ -f "$(which go)" ] ; then
if command -v go >/dev/null 2>&1 ; then
echo "Found golang, setting GOPROXY"
export GOPROXY=https://mirrors.tencent.com/go/
go env | grep 'PROXY'
fi

if [ -f "$(which R)" ] ; then
if command -v R >/dev/null 2>&1 ; then
echo "Found R, setting CRAN mirror"
echo "options(repos=structure(c(CRAN=\"http://mirrors.tencent.com/CRAN/\")))" >> /etc/R/Rprofile.site
echo "options(repos=structure(c(CRAN=\"http://mirrors.tencent.com/CRAN/\")))" | sudo tee -a /etc/R/Rprofile.site >/dev/null
R -e "options('repos');"
fi
Loading
Loading