Commit 70e10b1d authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Deduce mirror from URL

* fix: Deduce mirror from URL
parent ced994d9
Loading
Loading
Loading
Loading
+30 −16
Original line number Diff line number Diff line
@@ -21,8 +21,19 @@ fi
# Display wait message
/run/server.sh 5000 install &

# Detect country
DL=""
COUNTRY=""
DL_CHINA="https://cndl.synology.cn/download/DSM"
DL_GLOBAL="https://global.synologydownload.com/download/DSM"

[[ "${URL,,}" == *"cndl.synology"* ]] && DL="$DL_CHINA"
[[ "${URL,,}" == *"global.synology"* ]] && DL="$DL_GLOBAL"

if [ -z "$DL" ]; then

  info "Install: Selecting download mirror..."

  # Detect country
  { JSON=$(curl -sfk https://ipinfo.io/json); rc=$?; } || :

  if (( rc == 0 )); then
@@ -40,13 +51,14 @@ fi

  # Select download mirror based on country
  if [ "$COUNTRY" == "CN" ]; then
  DL="https://cndl.synology.cn/download/DSM"
    DL="$DL_CHINA"
  else
  DL="https://global.synologydownload.com/download/DSM"
    DL="$DL_GLOBAL"
  fi
fi

# Select default version based on architecture
if [ -z "$URL" ]; then
  # Select default version based on architecture
  if [ "$ARCH" == "amd64" ]; then
    URL="$DL/release/7.2.1/69057-1/DSM_VirtualDSM_69057.pat"
  else
@@ -68,6 +80,8 @@ rm -f "$STORAGE"/"$BASE".agent
rm -f "$STORAGE"/"$BASE".boot.img
rm -f "$STORAGE"/"$BASE".system.img

info "Install: Checking filesystem..."

[[ "${DEBUG}" == [Yy1]* ]] && set -x

# Check filesystem