mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 05:20:02 +08:00
feat: Country detection
* feat: Country detection
This commit is contained in:
parent
c1d3d15d4e
commit
354bd2429b
@ -14,7 +14,8 @@ ARG DEBIAN_FRONTEND noninteractive
|
|||||||
|
|
||||||
RUN apt-get update && apt-get -y upgrade && \
|
RUN apt-get update && apt-get -y upgrade && \
|
||||||
apt-get --no-install-recommends -y install \
|
apt-get --no-install-recommends -y install \
|
||||||
tini \
|
jq \
|
||||||
|
tini \
|
||||||
curl \
|
curl \
|
||||||
cpio \
|
cpio \
|
||||||
wget \
|
wget \
|
||||||
|
@ -21,17 +21,37 @@ fi
|
|||||||
# Display wait message
|
# Display wait message
|
||||||
/run/server.sh 5000 install &
|
/run/server.sh 5000 install &
|
||||||
|
|
||||||
# Download the required files from the Synology website
|
# Detect country
|
||||||
DL="https://global.synologydownload.com/download/DSM"
|
COUNTRY=""
|
||||||
|
{ JSON=$(curl -sfk https://ipinfo.io); rc=$?; } || :
|
||||||
|
|
||||||
|
if (( rc == 0 )); then
|
||||||
|
{ COUNTRY=$(echo "$JSON" | jq -r '.country' 2> /dev/null); rc=$?; } || :
|
||||||
|
(( rc != 0 )) || [[ "$COUNTRY" == "null" ]] && COUNTRY=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$COUNTRY" ]]; then
|
||||||
|
{ JSON=$(curl -sfk https://api.ipapi.is); rc=$?; } || :
|
||||||
|
if (( rc == 0 )); then
|
||||||
|
{ COUNTRY=$(echo "$JSON" | jq -r '.location.country_code' 2> /dev/null); rc=$?; } || :
|
||||||
|
(( rc != 0 )) || [[ "$COUNTRY" == "null" ]] && COUNTRY=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Select download mirror based on country
|
||||||
|
if [ "$COUNTRY" == "CN" ]; then
|
||||||
|
DL="https://cndl.synology.cn/download/DSM"
|
||||||
|
else
|
||||||
|
DL="https://global.synologydownload.com/download/DSM"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Select default version based on architecture
|
||||||
if [ -z "$URL" ]; then
|
if [ -z "$URL" ]; then
|
||||||
|
|
||||||
if [ "$ARCH" == "amd64" ]; then
|
if [ "$ARCH" == "amd64" ]; then
|
||||||
URL="$DL/release/7.2.1/69057-1/DSM_VirtualDSM_69057.pat"
|
URL="$DL/release/7.2.1/69057-1/DSM_VirtualDSM_69057.pat"
|
||||||
else
|
else
|
||||||
URL="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
URL="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if output is to interactive TTY
|
# Check if output is to interactive TTY
|
||||||
@ -83,6 +103,8 @@ if [[ "$TMP" != "$STORAGE/tmp" ]]; then
|
|||||||
(( MIN_SPACE > SPACE )) && error "Not enough free space for installation in ${STORAGE}, have ${SPACE_GB} GB available but need at least 6 GB." && exit 94
|
(( MIN_SPACE > SPACE )) && error "Not enough free space for installation in ${STORAGE}, have ${SPACE_GB} GB available but need at least 6 GB." && exit 94
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Download the required files from the Synology website
|
||||||
|
|
||||||
RDC="$STORAGE/dsm.rd"
|
RDC="$STORAGE/dsm.rd"
|
||||||
|
|
||||||
if [ ! -f "${RDC}" ]; then
|
if [ ! -f "${RDC}" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user