From 698516ac8c990104c801fc3593a19c68efc0b056 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 23 Dec 2023 18:46:14 +0100 Subject: [PATCH] feat: Detect country from timezone (#482) --- src/reset.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/reset.sh b/src/reset.sh index e6e8acf..54e3831 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -11,6 +11,7 @@ trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR # Docker environment variables +: ${TZ:=''} # System local timezone : ${GPU:='N'} # Disable GPU passthrough : ${KVM:='Y'} # Enable KVM acceleration : ${DEBUG:='N'} # Disable debugging mode @@ -70,6 +71,13 @@ getCountry () { setCountry () { + [[ "${TZ,,}" == "asia/harbin" ]] && COUNTRY="CN" + [[ "${TZ,,}" == "asia/beijing" ]] && COUNTRY="CN" + [[ "${TZ,,}" == "asia/urumqi" ]] && COUNTRY="CN" + [[ "${TZ,,}" == "asia/kashgar" ]] && COUNTRY="CN" + [[ "${TZ,,}" == "asia/shanghai" ]] && COUNTRY="CN" + [[ "${TZ,,}" == "asia/chongqing" ]] && COUNTRY="CN" + [ -z "$COUNTRY" ] && getCountry "https://api.ipapi.is" ".location.country_code" [ -z "$COUNTRY" ] && getCountry "https://ifconfig.co/json" ".country_iso" [ -z "$COUNTRY" ] && getCountry "https://ipinfo.io/json" ".country"