2022-02-09 05:18:29 -05:00
|
|
|
#!/bin/bash
|
|
|
|
export DIALOGOPTS='--insecure --no-lines --visit-items'
|
|
|
|
|
|
|
|
|
|
|
|
# Get the list of timezones
|
|
|
|
mapfile -t regions < <(timedatectl --no-pager list-timezones | cut -d '/' -f1 | sort -u)
|
|
|
|
|
|
|
|
# Use the same text twice here and just hide the tag field.
|
|
|
|
region=$(dialog --backtitle "Please select your Region" \
|
|
|
|
--no-tags \
|
|
|
|
--menu "Use up and down arrows or page-up and page-down to navigate the list, and press 'Enter' to make your selection." 0 0 0 \
|
|
|
|
$(for i in ${regions[@]} ; do echo "$i";echo "$i";done) --stdout)
|
|
|
|
|
|
|
|
|
|
|
|
mapfile -t cities < <(timedatectl --no-pager list-timezones | grep "$region" | cut -d '/' -f2 | sort -u)
|
|
|
|
|
|
|
|
# Use the same text twice here and just hide the tag field.
|
|
|
|
city=$(dialog --backtitle "Please select a city near you" \
|
|
|
|
--no-tags \
|
|
|
|
--menu "Use up and down arrow or page-up and page-down to navigate the list." 0 0 10 \
|
|
|
|
$(for i in ${cities[@]} ; do echo "$i";echo "$i";done) --stdout)
|
|
|
|
|
|
|
|
# Set the timezone
|
|
|
|
if [[ -f /etc/localtime ]]; then
|
2023-08-19 17:09:54 -04:00
|
|
|
sudo "${sudoFlags[@]}" rm /etc/localtime
|
2022-02-09 05:18:29 -05:00
|
|
|
fi
|
2024-03-12 16:45:56 -04:00
|
|
|
sudo "${sudoFlags[@]}" ln -sf /usr/share/zoneinfo/${region}/${city} /etc/localtime
|
2024-05-21 02:07:50 -04:00
|
|
|
sudo "${sudoFlags[@]}" timedatectl set-ntp true
|