2013-07-22 17:57:18 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-08-11 17:19:18 +02:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2008-10-20 22:39:25 +02:00
|
|
|
# written by Tobias Powalowski <tpowa@archlinux.org>
|
2023-09-03 22:02:48 +02:00
|
|
|
. /usr/lib/archboot/common.sh
|
2024-03-20 16:48:05 +01:00
|
|
|
_TITLE="archboot.com | ${_RUNNING_ARCH} | ${_RUNNING_KERNEL} | Basic Setup | Clock Configuration"
|
2023-07-13 14:56:53 +02:00
|
|
|
|
2023-07-14 15:34:35 +02:00
|
|
|
_hwclock() {
|
2023-01-09 18:17:27 +01:00
|
|
|
echo 0.0 0 0.0 > /etc/adjtime
|
|
|
|
echo 0 >> /etc/adjtime
|
2023-07-14 15:53:06 +02:00
|
|
|
echo UTC >> /etc/adjtime
|
|
|
|
timedatectl set-local-rtc 0
|
2008-10-20 22:39:25 +02:00
|
|
|
}
|
|
|
|
|
2023-07-14 15:34:35 +02:00
|
|
|
_timezone () {
|
2023-07-14 15:31:43 +02:00
|
|
|
_SET_ZONE=""
|
|
|
|
while [[ -z "${_SET_ZONE}" ]]; do
|
|
|
|
_CONTINUE=""
|
|
|
|
while [[ -z "${_CONTINUE}" ]]; do
|
|
|
|
_REGIONS="America - Europe - Africa - Asia - Australia -"
|
|
|
|
#shellcheck disable=SC2086
|
2023-07-15 13:53:54 +02:00
|
|
|
if _dialog --cancel-label "${_LABEL}" --title " Timezone Region " --menu "" 11 30 6 ${_REGIONS} 2>${_ANSWER}; then
|
2023-07-14 15:31:43 +02:00
|
|
|
_REGION=$(cat ${_ANSWER})
|
|
|
|
_ZONES=""
|
|
|
|
_CONTINUE=1
|
|
|
|
else
|
|
|
|
_abort
|
|
|
|
fi
|
|
|
|
done
|
2023-07-14 15:42:43 +02:00
|
|
|
_ZONES=""
|
2024-06-26 20:19:41 +02:00
|
|
|
for i in $(timedatectl --no-pager list-timezones | rg "${_REGION}" | sd '.*/' '' | sort -u); do
|
2023-07-14 15:42:43 +02:00
|
|
|
_ZONES="${_ZONES} ${i} -"
|
2023-07-14 15:31:43 +02:00
|
|
|
done
|
2023-07-14 15:42:43 +02:00
|
|
|
#shellcheck disable=SC2086
|
2023-09-06 09:09:26 +02:00
|
|
|
if _dialog --title " Timezone " --menu "" 21 30 16 ${_ZONES} 2>${_ANSWER}; then
|
2023-07-14 15:42:43 +02:00
|
|
|
_SET_ZONE="1"
|
|
|
|
_ZONE=$(cat ${_ANSWER})
|
|
|
|
[[ "${_ZONE}" == "${_REGION}" ]] || _ZONE="${_REGION}/${_ZONE}"
|
|
|
|
else
|
|
|
|
_SET_ZONE=""
|
|
|
|
fi
|
2023-01-09 09:05:40 +01:00
|
|
|
done
|
2023-08-03 16:06:56 +02:00
|
|
|
_dialog --title " Clock Configuration " --no-mouse --infobox "Setting Timezone to ${_ZONE}..." 3 50
|
2023-07-21 21:15:00 +02:00
|
|
|
timedatectl set-timezone "${_ZONE}"
|
2023-07-22 07:14:16 +02:00
|
|
|
sleep 2
|
2023-07-22 07:16:51 +02:00
|
|
|
}
|
2008-10-20 22:39:25 +02:00
|
|
|
|
2023-07-14 15:34:35 +02:00
|
|
|
_timeset() {
|
2023-07-14 15:47:11 +02:00
|
|
|
_hwclock
|
|
|
|
if [[ -z "${_SET_TIME}" ]]; then
|
|
|
|
timedatectl set-ntp 0
|
2023-07-14 16:01:57 +02:00
|
|
|
# display and ask to set date/time
|
2024-06-27 08:11:02 +02:00
|
|
|
_dialog --title " Date " --no-cancel --date-format '%F' --calendar "Use <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2>"${_ANSWER}"
|
2023-07-21 15:27:59 +02:00
|
|
|
_DATE="$(cat "${_ANSWER}")"
|
|
|
|
_dialog --title " Time " --no-cancel --timebox "Use <TAB> to navigate and up/down to change values." 0 0 2>"${_ANSWER}"
|
|
|
|
_TIME="$(cat "${_ANSWER}")"
|
2023-07-14 15:47:11 +02:00
|
|
|
# save the time
|
2024-07-25 07:48:17 +02:00
|
|
|
#shellcheck disable=SC2027
|
2024-06-26 22:47:46 +02:00
|
|
|
_DATETIME=""${_DATE}" "${_TIME}""
|
2023-07-14 15:47:11 +02:00
|
|
|
timedatectl set-time "${_DATETIME}"
|
2023-07-14 16:20:37 +02:00
|
|
|
_SET_TIME="1"
|
2023-07-14 15:47:11 +02:00
|
|
|
fi
|
2023-08-03 16:06:56 +02:00
|
|
|
_dialog --title " Clock Configuration " --no-mouse --infobox "Clock configuration completed successfully." 3 50
|
2023-08-01 19:56:04 +02:00
|
|
|
sleep 2
|
|
|
|
}
|
|
|
|
|
2023-08-31 08:04:05 +02:00
|
|
|
_task_clock() {
|
2023-08-01 19:56:04 +02:00
|
|
|
timedatectl set-timezone "${_ZONE}"
|
|
|
|
_hwclock
|
|
|
|
# sync immediatly with standard pool
|
|
|
|
systemctl restart systemd-timesyncd
|
|
|
|
# enable background syncing
|
|
|
|
timedatectl set-ntp 1
|
2023-08-31 08:07:18 +02:00
|
|
|
rm /.archboot
|
2023-08-31 08:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_auto_clock() {
|
|
|
|
: > /.archboot
|
|
|
|
_task_clock &
|
2024-02-25 16:28:40 +01:00
|
|
|
_progress_wait "0" "99" "Using ${_ZONE} and enable NTP timesyncd..." "1"
|
2023-08-31 14:19:07 +02:00
|
|
|
_progress "100" "${_ZONE} configuration completed successfully."
|
2023-08-01 19:57:21 +02:00
|
|
|
sleep 2
|
2008-10-20 22:39:25 +02:00
|
|
|
}
|
2023-03-07 17:29:18 +01:00
|
|
|
|
2023-07-17 08:34:15 +02:00
|
|
|
_check
|
2023-07-14 15:47:11 +02:00
|
|
|
_SET_TIME=""
|
2023-08-01 19:56:04 +02:00
|
|
|
# automatic setup
|
2023-08-25 12:19:47 +02:00
|
|
|
if ping -c1 www.google.com &>"${_NO_LOG}"; then
|
2023-09-04 14:58:39 +02:00
|
|
|
_ZONE="$(${_DLPROG} "http://ip-api.com/csv/?fields=timezone")"
|
2023-08-31 14:14:49 +02:00
|
|
|
_auto_clock | _dialog --title " Clock Configuration " --no-mouse --gauge "Using ${_ZONE} and enable NTP timesyncd..." 6 70 0
|
2023-08-01 19:57:21 +02:00
|
|
|
_SET_TIME="1"
|
2023-08-01 19:56:04 +02:00
|
|
|
fi
|
2023-07-14 15:47:11 +02:00
|
|
|
while [[ -z "${_SET_TIME}" ]]; do
|
2023-07-14 16:34:34 +02:00
|
|
|
_timezone
|
|
|
|
_timeset
|
2023-07-14 15:47:11 +02:00
|
|
|
done
|
2023-07-17 08:34:15 +02:00
|
|
|
_cleanup
|