Skip to content

Commit

Permalink
feat: 自动检测国家
Browse files Browse the repository at this point in the history
  • Loading branch information
xbingW committed Jun 14, 2024
1 parent 3cd6cc6 commit fac90ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions release/latest/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ echo "MGT_PORT=9443" >> .env
echo "POSTGRES_PASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
echo "SUBNET_PREFIX=$SUBNET_PREFIX" >> .env

if [ -z "$CDN" ]; then
if [[ $(curl -s ipinfo.io/country) == "CN" ]]; then
CDN=1
else
CDN=0
fi
fi

if [ $CDN -eq 0 ]; then
echo "IMAGE_PREFIX=chaitin" >>".env"
else
Expand Down
7 changes: 7 additions & 0 deletions release/latest/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ grep "MGT_PORT" ".env" >/dev/null || echo "MGT_PORT=9443" >>".env"
grep "POSTGRES_PASSWORD" ".env" >/dev/null || echo "POSTGRES_PASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >>".env"
grep "SUBNET_PREFIX" ".env" >/dev/null || echo "SUBNET_PREFIX=172.22.222" >>".env"

if [ -z "$CDN" ]; then
if [[ $(curl -s ipinfo.io/country) == "CN" ]]; then
CDN=1
else
CDN=0
fi
fi

if [ $CDN -eq 0 ]; then
sed -i "s/IMAGE_PREFIX=.*/IMAGE_PREFIX=chaitin/g" ".env"
Expand Down

0 comments on commit fac90ae

Please sign in to comment.