mirror of
https://github.com/AuxXxilium/arc.git
synced 2024-11-24 02:49:54 +07:00
arc: rewrite timezone/region check
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
3fba97c0c9
commit
949ab7fe2e
@ -19,6 +19,8 @@ ARCBRANCH="$(readConfigKey "arc.branch" "${USER_CONFIG_FILE}")"
|
|||||||
BUS=$(getBus "${LOADER_DISK}")
|
BUS=$(getBus "${LOADER_DISK}")
|
||||||
# Check if machine has EFI
|
# Check if machine has EFI
|
||||||
[ -d /sys/firmware/efi ] && EFI=1 || EFI=0
|
[ -d /sys/firmware/efi ] && EFI=1 || EFI=0
|
||||||
|
# NTP Check
|
||||||
|
localtime
|
||||||
|
|
||||||
# Print Title centralized
|
# Print Title centralized
|
||||||
clear
|
clear
|
||||||
|
@ -533,6 +533,9 @@ function ntpCheck() {
|
|||||||
local KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
|
local KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
|
||||||
if [ "${OFFLINE}" == "false" ]; then
|
if [ "${OFFLINE}" == "false" ]; then
|
||||||
# Timezone
|
# Timezone
|
||||||
|
local REGION="$(readConfigKey "time.region" "${USER_CONFIG_FILE}")"
|
||||||
|
local TIMEZONE="$(readConfigKey "time.timezone" "${USER_CONFIG_FILE}")"
|
||||||
|
if [ -z "${REGION}" ] || [ -z "${TIMEZONE}" ]; then
|
||||||
if [ "${ARCNIC}" == "auto" ]; then
|
if [ "${ARCNIC}" == "auto" ]; then
|
||||||
local REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
|
local REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
|
||||||
local TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
|
local TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
|
||||||
@ -544,11 +547,15 @@ function ntpCheck() {
|
|||||||
fi
|
fi
|
||||||
writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}"
|
writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}"
|
||||||
writeConfigKey "time.timezone" "${TIMEZONE}" "${USER_CONFIG_FILE}"
|
writeConfigKey "time.timezone" "${TIMEZONE}" "${USER_CONFIG_FILE}"
|
||||||
|
fi
|
||||||
|
if [ -n "${REGION}" ] && [ -n "${TIMEZONE}" ]; then
|
||||||
ln -fs /usr/share/zoneinfo/${REGION}/${TIMEZONE} /etc/localtime
|
ln -fs /usr/share/zoneinfo/${REGION}/${TIMEZONE} /etc/localtime
|
||||||
|
TZ="${REGION}/${TIMEZONE}"
|
||||||
# NTP
|
# NTP
|
||||||
/etc/init.d/S49ntpd restart > /dev/null 2>&1
|
/etc/init.d/S49ntpd restart > /dev/null 2>&1
|
||||||
#hwclock --systohc > /dev/null 2>&1
|
#hwclock --systohc > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [ -z "${LAYOUT}" ]; then
|
if [ -z "${LAYOUT}" ]; then
|
||||||
[ -n "${KEYMAP}" ] && KEYMAP="$(echo ${KEYMAP} | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]' | tr -d '[:punct:]' | tr -d '[:digit:]')"
|
[ -n "${KEYMAP}" ] && KEYMAP="$(echo ${KEYMAP} | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]' | tr -d '[:punct:]' | tr -d '[:digit:]')"
|
||||||
[ -n "${KEYMAP}" ] && writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}"
|
[ -n "${KEYMAP}" ] && writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}"
|
||||||
|
Loading…
Reference in New Issue
Block a user