mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
simplify tz
This commit is contained in:
parent
ec72a69946
commit
f538cb89a7
3 changed files with 20 additions and 76 deletions
|
@ -66,6 +66,7 @@ if ! _set_vconsole; then
|
||||||
clear
|
clear
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
[[ -e /tmp/.km ]] && rm /tmp/.km
|
||||||
[[ -e /tmp/.km-running ]] && rm /tmp/.km-running
|
[[ -e /tmp/.km-running ]] && rm /tmp/.km-running
|
||||||
_do_vconsole
|
_do_vconsole
|
||||||
clear
|
clear
|
||||||
|
|
|
@ -13,17 +13,6 @@ _dialog() {
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
_abort()
|
|
||||||
{
|
|
||||||
_dialog --yesno "Abort Time And Date Setting?" 6 40 || return 0
|
|
||||||
[[ -e /tmp/.tz ]] && rm -f /tmp/.tz
|
|
||||||
[[ -e /etc/localtime ]] && rm -f /etc/localtime
|
|
||||||
[[ -e /etc/adjtime ]] && rm -f /etc/adjtime
|
|
||||||
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
|
||||||
clear
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
_dohwclock() {
|
_dohwclock() {
|
||||||
echo 0.0 0 0.0 > /etc/adjtime
|
echo 0.0 0 0.0 > /etc/adjtime
|
||||||
echo 0 >> /etc/adjtime
|
echo 0 >> /etc/adjtime
|
||||||
|
@ -57,9 +46,7 @@ _dotimezone () {
|
||||||
if [[ -n "${_SET_ZONE}" ]]; then
|
if [[ -n "${_SET_ZONE}" ]]; then
|
||||||
_dialog --infobox "Setting Timezone to ${_ZONE}..." 0 0
|
_dialog --infobox "Setting Timezone to ${_ZONE}..." 0 0
|
||||||
timedatectl set-timezone "${_ZONE}"
|
timedatectl set-timezone "${_ZONE}"
|
||||||
_S_NEXTITEM="2"
|
|
||||||
else
|
else
|
||||||
_S_NEXTITEM="1"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -68,7 +55,6 @@ _dotimezone () {
|
||||||
_dotimeset() {
|
_dotimeset() {
|
||||||
if [[ -z "${_SET_ZONE}" ]]; then
|
if [[ -z "${_SET_ZONE}" ]]; then
|
||||||
_dialog --msgbox "Error:\nYou have to select timezone first." 0 0
|
_dialog --msgbox "Error:\nYou have to select timezone first." 0 0
|
||||||
_S_NEXTITEM="1"
|
|
||||||
dotimezone || return 1
|
dotimezone || return 1
|
||||||
fi
|
fi
|
||||||
_SET_TIME=""
|
_SET_TIME=""
|
||||||
|
@ -85,7 +71,6 @@ _dotimeset() {
|
||||||
# sync immediatly with standard pool
|
# sync immediatly with standard pool
|
||||||
if ! systemctl restart systemd-timesyncd; then
|
if ! systemctl restart systemd-timesyncd; then
|
||||||
_dialog --msgbox "An error has occured, time was not changed!" 0 0
|
_dialog --msgbox "An error has occured, time was not changed!" 0 0
|
||||||
_S_NEXTITEM="2"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# enable background syncing
|
# enable background syncing
|
||||||
|
@ -96,18 +81,9 @@ _dotimeset() {
|
||||||
if [[ -z "${_SET_TIME}" ]]; then
|
if [[ -z "${_SET_TIME}" ]]; then
|
||||||
timedatectl set-ntp 0
|
timedatectl set-ntp 0
|
||||||
# display and ask to set date/time
|
# display and ask to set date/time
|
||||||
_CANCEL=""
|
dialog --calendar "Set the date.\nUse <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2> ${_ANSWER} || return 1
|
||||||
dialog --calendar "Set the date.\nUse <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2> ${_ANSWER} || _CANCEL="1"
|
|
||||||
if [[ -n "${_CANCEL}" ]]; then
|
|
||||||
_S_NEXTITEM="2"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_DATE="$(cat ${_ANSWER})"
|
_DATE="$(cat ${_ANSWER})"
|
||||||
dialog --timebox "Set the time.\nUse <TAB> to navigate and up/down to change values." 0 0 2> ${_ANSWER} || _CANCEL="1"
|
dialog --timebox "Set the time.\nUse <TAB> to navigate and up/down to change values." 0 0 2> ${_ANSWER} || return 1
|
||||||
if [[ -n "${_CANCEL}" ]]; then
|
|
||||||
_S_NEXTITEM="2"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_TIME="$(cat ${_ANSWER})"
|
_TIME="$(cat ${_ANSWER})"
|
||||||
# save the time
|
# save the time
|
||||||
# DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss
|
# DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss
|
||||||
|
@ -117,35 +93,6 @@ _dotimeset() {
|
||||||
fi
|
fi
|
||||||
_dialog --cr-wrap --defaultno --yesno "Your current time and date is:\n$(${_DATE_PROGRAM})\n\nDo you want to change it?" 0 0 && _SET_TIME=""
|
_dialog --cr-wrap --defaultno --yesno "Your current time and date is:\n$(${_DATE_PROGRAM})\n\nDo you want to change it?" 0 0 && _SET_TIME=""
|
||||||
done
|
done
|
||||||
_S_NEXTITEM="3"
|
|
||||||
}
|
|
||||||
|
|
||||||
_mainmenu() {
|
|
||||||
if [[ -n "${_S_NEXTITEM}" ]]; then
|
|
||||||
_DEFAULT="--default-item ${_S_NEXTITEM}"
|
|
||||||
else
|
|
||||||
_DEFAULT=""
|
|
||||||
fi
|
|
||||||
#shellcheck disable=SC2086
|
|
||||||
_dialog ${_DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
|
|
||||||
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 11 58 13 \
|
|
||||||
"1" "Select Timezone" \
|
|
||||||
"2" "Set Time and Date" \
|
|
||||||
"3" "${_EXIT}" 2>${_ANSWER}
|
|
||||||
case $(cat ${_ANSWER}) in
|
|
||||||
"1")
|
|
||||||
_dotimezone
|
|
||||||
;;
|
|
||||||
"2")
|
|
||||||
_dotimeset
|
|
||||||
;;
|
|
||||||
"3")
|
|
||||||
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
|
||||||
clear
|
|
||||||
exit 0 ;;
|
|
||||||
*)
|
|
||||||
_abort ;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -e /tmp/.tz-running ]]; then
|
if [[ -e /tmp/.tz-running ]]; then
|
||||||
|
@ -154,24 +101,20 @@ if [[ -e /tmp/.tz-running ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
: >/tmp/.tz-running
|
: >/tmp/.tz-running
|
||||||
if [[ "${1}" = "--setup" ]]; then
|
if ! _dotimezone; then
|
||||||
if ! _dotimezone; then
|
[[ -e /tmp/.tz ]] && rm /tmp/.tz
|
||||||
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
||||||
clear
|
clear
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
if ! _dotimeset; then
|
|
||||||
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
|
||||||
clear
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
_EXIT="Exit"
|
|
||||||
fi
|
fi
|
||||||
while true; do
|
if ! _dotimeset; then
|
||||||
_mainmenu
|
[[ -e /tmp/.tz ]] && rm /tmp/.tz
|
||||||
done
|
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
||||||
|
clear
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
[[ -e /tmp/.tz ]] && rm /tmp/.tz
|
||||||
|
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
||||||
clear
|
clear
|
||||||
exit 0
|
exit 0
|
||||||
# vim: set ts=4 sw=4 et:
|
# vim: set ts=4 sw=4 et:
|
||||||
|
|
|
@ -136,9 +136,9 @@ _set_guid() {
|
||||||
|
|
||||||
_set_vconsole() {
|
_set_vconsole() {
|
||||||
if [[ -e /usr/bin/km ]]; then
|
if [[ -e /usr/bin/km ]]; then
|
||||||
km --setup && _NEXTITEM=1
|
km && _NEXTITEM=1
|
||||||
elif [[ -e /usr/bin/archboot-km.sh ]]; then
|
elif [[ -e /usr/bin/archboot-km.sh ]]; then
|
||||||
archboot-km.sh --setup && _NEXTITEM=1
|
archboot-km.sh && _NEXTITEM=1
|
||||||
else
|
else
|
||||||
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
|
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
|
||||||
fi
|
fi
|
||||||
|
@ -164,9 +164,9 @@ _select_source() {
|
||||||
|
|
||||||
_set_clock() {
|
_set_clock() {
|
||||||
if [[ -e /usr/bin/tz ]]; then
|
if [[ -e /usr/bin/tz ]]; then
|
||||||
tz --setup && _NEXTITEM="4"
|
tz && _NEXTITEM="4"
|
||||||
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
|
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
|
||||||
archboot-tz.sh --setup && _NEXTITEM="4"
|
archboot-tz.sh && _NEXTITEM="4"
|
||||||
else
|
else
|
||||||
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
|
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue