summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-03-30 21:57:13 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2009-03-30 21:57:13 +0200
commit84424e82e5407315d2cedfe33c45629ffd8b56d8 (patch)
treec90e97486afccd6148975c802b6196798a67acb1 /src
parent940dde541435a9af38dc2c4c8a1f498dd21e5308 (diff)
fix hwclock calls for systohc and hctosys, fix /etc/localtime, show nice dialog with 'ok', 'manual date setting' and ntp using
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-misc.sh8
-rw-r--r--src/core/libs/lib-ui-interactive.sh55
2 files changed, 40 insertions, 23 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index e09f3c8..1e8df8e 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -103,18 +103,20 @@ cleanup_runtime ()
# $1 UTC or localtime (hardwareclock)
+# $2 direction (systohc or hctosys)
dohwclock() {
+ # TODO: we probably only need to do this once and then actually use adjtime on next invocations
infofy "Resetting hardware clock adjustment file"
[ ! -d /var/lib/hwclock ] && mkdir -p /var/lib/hwclock
if [ ! -f /var/lib/hwclock/adjtime ]; then
echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
fi
- infofy "Syncing hardwareclock to systemclock ..."
+ infofy "Syncing clocks ($2), hc being $1 ..."
if [ "$1" = "UTC" ]; then
- hwclock --utc
+ hwclock --$2 --utc
else
- hwclock --localtime
+ hwclock --$2 --localtime
fi
}
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 129b2cd..9884cb5 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -76,7 +76,6 @@ interactive_timezone () {
ask_timezone || return 1
TIMEZONE=$ANSWER_TIMEZONE
infofy "Setting Timezone to $TIMEZONE"
- [ -e /etc/localtime ] && rm -f /etc/localtime #why do we do this?? tpowa?
}
@@ -85,32 +84,48 @@ interactive_time () {
# utc or localtime?
ask_option UTC "Clock configuration" "Is your hardware clock in UTC or local time? UTC is recommended" required "UTC" " " "localtime" " " || return 1
HARDWARECLOCK=$ANSWER_OPTION
-
- dohwclock $HARDWARECLOCK
-
- if which ntpdate >/dev/null && ask_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!)" yes #TODO: only propose if network ok.
- then
- if ntpdate pool.ntp.org >/dev/null
+ [ -e /etc/localtime ] && rm -f /etc/localtime
+
+ while true; do
+ dohwclock $HARDWARECLOCK hctosys
+ current=`date`
+ default=no
+ [ -n "$NEXTITEM" ] && default="$NEXTITEM"
+ EXTRA=
+ #TODO: only propose if network ok
+ which ntpdate >/dev/null && EXTRA="'ntp' 'Set time and date using ntp'"
+
+ ask_option $default "Date/time configuration" "According to your settings and your hardwareclock, the date should now be $current. If this is incorrect, you can correct this now" required \
+ $EXTRA "manual" "Set time and date manually" \
+ "return" "Looks good. back to main menu"
+ if [ "$ANSWER_OPTION" = ntp ]
then
- notify "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)"
- else
- show_warning 'Ntp failure' "An error has occured, time was not changed!"
- fi
- fi
-
- # display and ask to set date/time
- ask_datetime
-
+ if ntpdate pool.ntp.org >/dev/null
+ then
+ notify "Synced clock with internet pool successfully."
+ NEXTITEM=3
+ else
+ show_warning 'Ntp failure' "An error has occured, time was not changed!"
+ fi
+ fi
+ if [ "$ANSWER_OPTION" = manual ]
+ then
+ ask_datetime
+ if date -s "$ANSWER_DATETIME"
+ then
+ dohwclock $HARDWARECLOCK systohc && NEXTITEM=3
+ else
+ show_warning "Date/time setting failed" "Something went wrong when doing date -s $ANSWER_DATETIME"
+ fi
+ fi
+ [ "$ANSWER_OPTION" = return ] && break
+ done
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
then
/bin/rm -f /etc/localtime
/bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
-
- # save the time
- date -s "$ANSWER_DATETIME" || show_warning "Date/time setting failed" "Something went wrong when doing date -s $ANSWER_DATETIME"
- dohwclock
}