Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147916653
D52057.1784779543.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D52057.1784779543.diff
View Options
diff --git a/usr.sbin/bsdinstall/scripts/time b/usr.sbin/bsdinstall/scripts/time
--- a/usr.sbin/bsdinstall/scripts/time
+++ b/usr.sbin/bsdinstall/scripts/time
@@ -36,29 +36,59 @@
TZ="${BSDINSTALL_CHROOT}/etc/localtime"
export TZ
-# Set date
-exec 5>&1
-DATE=$(bsddialog --backtitle "$OSNAME Installer" \
- --title 'Time & Date' \
- --ok-label 'Set Date' \
- --cancel-label 'Skip' \
- --default-no \
- --date-format '%Y%m%d%H%M.%S' \
- --calendar '' 0 40 \
-2>&1 1>&5) && date $DATE
-exec 5>&-
+set_datetime_auto()
+{
+ if ! host freebsd.pool.ntp.org >/dev/null 2>&1; then
+ return 1
+ fi
+ if ! f_yesno "Attempt to set the date and time automatically?"; then
+ return 1
+ fi
+ local ntperr
+ if ! ntperr=$(ntpdate freebsd.pool.ntp.org 2>&1 | sed 's/^.*\]: //'); then
+ f_show_info "Failed to set the date and time:
-# Set time
-exec 5>&1
-TIME=$(bsddialog --backtitle "$OSNAME Installer" \
- --title 'Time & Date' \
- --ok-label 'Set Time' \
- --cancel-label 'Skip' \
- --default-no \
- --time-format '%H%M.%S' \
- --timebox '' 0 40 \
-2>&1 1>&5) && date $TIME
-exec 5>&-
+${ntperr}"
+ return 1
+ fi
+ f_show_info "The date and time were successfully set."
+ return 0
+}
+
+set_datetime_manual()
+{
+ # Set date
+ exec 5>&1
+ local date
+ if date=$(bsddialog --backtitle "$OSNAME Installer" \
+ --title 'Time & Date' \
+ --ok-label 'Set Date' \
+ --cancel-label 'Skip' \
+ --default-no \
+ --date-format '%Y%m%d%H%M.%S' \
+ --calendar '' 0 40 \
+ 2>&1 1>&5); then
+ date ${date}
+ fi
+ exec 5>&-
+
+ # Set time
+ exec 5>&1
+ local time
+ if time=$(bsddialog --backtitle "$OSNAME Installer" \
+ --title 'Time & Date' \
+ --ok-label 'Set Time' \
+ --cancel-label 'Skip' \
+ --default-no \
+ --time-format '%H%M.%S' \
+ --timebox '' 0 40 \
+ 2>&1 1>&5); then
+ date ${time}
+ fi
+ exec 5>&-
+}
+
+set_datetime_auto || set_datetime_manual
# Switch back
if [ -n "$saved_TZ" ]; then
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 4:05 AM (13 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29235115
Default Alt Text
D52057.1784779543.diff (1 KB)
Attached To
Mode
D52057: bsdinstall: Attempt setting the date with NTP
Attached
Detach File
Event Timeline
Log In to Comment