dodialog yesno "Your current BIOS time is:\n$(hwclock)\n\nIf your BIOS clock is set to UTC choose YES\nOtherwise (or if unsure) choose NO" 15 65 && CLOCKSOURCE="UTC"
dodialog msgbox "Skipping Region and Timezone, else please select a Timezone!"
fi
else
dodialog msgbox "Skipping Region and Timezone, else please select correct Region first!"
fi
S_NEXTITEM="2"
}
dotimeset() {
USE_UTC=""
SET_TIME=""
USE_NTPDATE=""
### check disabled for now!
#if [ ! -s /tmp/.timezone ]; then
# dodialog msgbox "You have not selected a region and timezone,\nplease select one!"
# S_NEXTITEM="1"
# return 1
#fi
dodialog yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used,\nwhich means the system will not change the time.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC"
dodialog infobox "Syncing hardwareclock to systemclock ..."
[ $(which ntpdate) ] && dodialog yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" "" "" default=no && USE_NTPDATE="1"
if [ "${USE_NTPDATE}" = "1" ]; then
if [ ! $(ntpdate pool.ntp.org) ]; then
dodialog msgbox "An error has occured, time was not changed!"
S_NEXTITEM="2"
return 1
fi
dodialog msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)"
else
dodialog inputbox "Your current time is:\n$(date)\n\nSyntax of your current time is:\n$(date +%m%d%H%M%y)\nMMDDhhmmYY\n\nPlease enter your correct time below,\naccording to the syntax.\n " 17 60 "" 2>$ANSWER || return 1
if [ ! $(cat $ANSWER) = "" ]; then
if [ ! $(date $(cat $ANSWER)) ]; then
dodialog msgbox "An error occured during time setting,\ncurrent time was not changed!"
S_NEXTITEM="2"
return 1
fi
else
dodialog msgbox "You entered nothing, current time was not changed!"
S_NEXTITEM="2"
return 1
fi
dodialog infobox "Syncing systemclock to hardwareclock ..."
HWCLOCK_PARAMS="--systohc"
dohwclock
dodialog msgbox "Your current time is now:\n$(date)"
fi
fi
S_NEXTITEM="3"
}
mainmenu() {
if [ -n "$S_NEXTITEM" ]; then
DEFAULT="--default-item $S_NEXTITEM"
else
DEFAULT=""
fi
dialog $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \
--menu "Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." 15 55 8 \
"1" "Select Region and Timezone" \
"2" "Set Date and Time" \
"3" "Exit Time Setting" 2>$ANSWER
case $(cat $ANSWER) in
"1")
dotimezone
;;
"2")
dotimeset
;;
"3")
exit 0 ;;
*)
abort ;;
esac
}
loop() {
while $(/bin/true); do
mainmenu
done
}
: >/tmp/.hardwareclock
: >/tmp/.timezone
if [ ! -d $BASEDIR ]; then
echo "Cannot load timezone data, as none were found in $BASEDIR" >&2