Unverified Commit 698516ac authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Detect country from timezone (#482)

parent dae5d756
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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"