summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-misc.sh17
-rw-r--r--src/core/libs/lib-ui-interactive.sh60
-rw-r--r--src/core/libs/lib-ui.sh20
-rw-r--r--src/core/procedures/base24
4 files changed, 91 insertions, 30 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index c7a5d2f..ac66bd1 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -68,3 +68,20 @@ cleanup_runtime ()
mkdir -p $RUNTIME_DIR || die_error "Cannot create $RUNTIME_DIR"
rm -rf $RUNTIME_DIR/aif-dia* &>/dev/null
}
+
+
+dohwclock() {
+ infofy "Syncing hardwareclock to systemclock ..."
+ if [ "$HARDWARECLOCK" = "UTC" ]; then
+ HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc"
+ else
+ HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime"
+ fi
+
+ [ ! -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 # what the hell is this for???
+ fi
+ hwclock $HWCLOCK_PARAMS #tpowa does it without, but i would add --noadjtime here
+}
+
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 804d3c3..f99518e 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -57,48 +57,52 @@ interactive_configure_system()
}
-# set_clock()
-# prompts user to set hardware clock and timezone
-#
-# params: none
-# returns: 1 on failure
-interactive_set_clock()
-{
- # utc or localtime?
- ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "localtime" " " || return 1
- HARDWARECLOCK=$ANSWER_OPTION
-
- # timezone?
+interactive_timezone () {
ask_timezone || return 1
- TIMEZONE=$ANSWER_TIMEZONE
+ TIMEZONE=$ANSWER_TIMEZONE
+ infofy "Setting Timezone to $TIMEZONE"
+ [ -e /etc/localtime ] && rm -f /etc/localtime #why do we do this?? tpowa?
+ dohwclock
+}
+
+
+
+interactive_time () {
+ # utc or localtime?
+ ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "localtime" " " || return 1
+ HARDWARECLOCK=$ANSWER_OPTION
+
+ dohwclock
+
+ which ntpdate >/dev/null && ask_option yes "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?" "(You need a working internet connection for doing this!)" #TODO: only propose if network ok.
+ if [ $? -eq 0 ]; then
+ if ntpdate pool.ntp.org >/dev/null
+ 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
+ else
+
+ # display and ask to set date/time
+ ask_datetime
- # set system clock from hwclock - stolen from rc.sysinit
- local HWCLOCK_PARAMS=""
- if [ "$HARDWARECLOCK" = "UTC" ]
- then
- HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc"
- else
- HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime"
- fi
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
then
/bin/rm -f /etc/localtime
/bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
- /sbin/hwclock --hctosys $HWCLOCK_PARAMS --noadjfile
-
- # display and ask to set date/time
- ask_datetime
# save the time
date -s "$ANSWER_DATETIME" || show_warning "Date/time setting failed" "Something went wrong when doing date -s $ANSWER_DATETIME"
- /sbin/hwclock --systohc $HWCLOCK_PARAMS --noadjfile
-
- return 0
+ dohwclock
}
+
+
+
interactive_autoprepare()
{
DISCS=$(finddisks)
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index 70cf9e3..aa1171c 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -395,7 +395,25 @@ _dia_ask_string ()
_dia_ask_timezone ()
{
- ANSWER_TIMEZONE=`tzselect` #TODO: implement nicer then this
+ REGIONS=""
+ SET_ZONE=""
+ for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do
+ REGIONS="$REGIONS $i -"
+ done
+ while ! [ "$SET_ZONE" = "1" ]; do
+ SET_REGION=""
+ ask_option no "Please select a region" '' $REGIONS
+ region=ANSWER_OPTION
+ if [ $? -eq 0 ]; then
+ ZONES=""
+ for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do
+ ZONES="$ZONES $i -"
+ done
+ ask_option no "Please select a timezone" '' $ZONES
+ zone=$ANSWER_OPTION
+ [ $? -gt 0 ] && ANSWER_TIMEZONE="$region/$zone" && return
+ fi
+ done
}
diff --git a/src/core/procedures/base b/src/core/procedures/base
index cf4e7e2..845ce2d 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -101,7 +101,29 @@ worker_runtime_packages ()
worker_set_clock ()
{
- interactive_set_clock
+ while true; do
+ default=no
+ [ -n "$NEXTITEM" ] && default="$NEXTITEM"
+ ask_option $default "Date/time configuration" '' \
+ "1" "Select region and timezone" \
+ "2" "Set time and date" \
+ "3" "Return to Main Menu"
+ [ "$ANSWER_OPTION" = 1 ] && execute worker interactive_timezone && NEXTITEM=2
+ [ "$ANSWER_OPTION" = 2 ] && check_depend worker interactive_timezone && execute worker interactive_time && NEXTITEM=3
+ [ "$ANSWER_OPTION" = 3 ] && break
+ done
+}
+
+
+worker_interactive_timezone ()
+{
+ interactive_timezone
+}
+
+
+worker_interactive_time ()
+{
+ interactive_time
}