mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
add ntpd and change tz to systemd style
This commit is contained in:
parent
a1fc0e3816
commit
bf3f8c996e
2 changed files with 19 additions and 30 deletions
|
@ -6,6 +6,7 @@ build ()
|
|||
add_binary "/sbin/hwclock"
|
||||
add_binary "/bin/date"
|
||||
add_binary "/usr/bin/ntpdate"
|
||||
add_binary "/usr/bin/ntpd"
|
||||
for i in $(find /usr/share/zoneinfo ! -type d); do
|
||||
add_file $i
|
||||
done
|
||||
|
|
|
@ -35,20 +35,23 @@ DIALOG() {
|
|||
}
|
||||
|
||||
dohwclock() {
|
||||
if [[ "${HARDWARECLOCK}" = "UTC" ]]; then
|
||||
HWCLOCK_PARAMS="${HWCLOCK_PARAMS} --utc"
|
||||
echo UTC > /tmp/.hardwareclock
|
||||
else
|
||||
HWCLOCK_PARAMS="${HWCLOCK_PARAMS} --localtime"
|
||||
echo LOCAL > /tmp/.hardwareclock
|
||||
fi
|
||||
|
||||
if [[ ! -f /etc/adjtime ]]; then
|
||||
echo "0.0 0 0.0" > /etc/adjtime
|
||||
echo "0" >> /etc/adjtime
|
||||
[[ -s /tmp/.hardwareclock ]] && cat /tmp/.hardwareclock >>/etc/adjtime
|
||||
[[ "${HARDWARECLOCK}" = "UTC" ]] && echo UTC >> /etc/adjtime
|
||||
[[ "${HARDWARECLOCK}" = "" ]] && echo LOCAL >> /etc/adjtime
|
||||
fi
|
||||
if [[ "${HARDWARECLOCK}" = "UTC" ]]; then
|
||||
timedatectl set-local-rtc 0
|
||||
DATE_PROGRAM=$(timedatectl)
|
||||
# for setup script
|
||||
echo UTC > /tmp/.hardwareclock
|
||||
else
|
||||
timedatectl set-local-rtc 1
|
||||
DATE_PROGRAM=$(date)
|
||||
# for setup script
|
||||
echo LOCAL > /tmp/.hardwareclock
|
||||
fi
|
||||
hwclock ${HWCLOCK_PARAMS}
|
||||
}
|
||||
|
||||
dotimezone () {
|
||||
|
@ -76,16 +79,15 @@ dotimeset() {
|
|||
SET_TIME=""
|
||||
USE_NTPDATE=""
|
||||
HARDWARECLOCK=""
|
||||
DATE_PROGRAM=""
|
||||
if [[ ! -s /tmp/.timezone ]]; then
|
||||
DIALOG --msgbox "Error:\nYou have to select timezone first." 0 0
|
||||
S_NEXTITEM="1"
|
||||
dotimezone || return 1
|
||||
fi
|
||||
DIALOG --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, which means\nthe system will not change the time automatically.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC"
|
||||
DIALOG --infobox "Syncing hardwareclock to systemclock ..." 0 0
|
||||
HWCLOCK_PARAMS="--hctosys"
|
||||
dohwclock
|
||||
DIALOG --yesno "Your current time and date is:\n$(date)\n\nDo you want to change it?" 0 0 && SET_TIME="1"
|
||||
DIALOG --cr-wrap --yesno "Your current time and date is:\n${DATE_PROGRAM}\n\nDo you want to change it?" 0 0 && SET_TIME="1"
|
||||
if [[ "${SET_TIME}" = "1" ]]; then
|
||||
[[ $(which ntpdate) ]] && DIALOG --defaultno --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!)" 0 0 && USE_NTPDATE="1"
|
||||
if [[ "${USE_NTPDATE}" = "1" ]]; then
|
||||
|
@ -94,7 +96,7 @@ if [[ "${SET_TIME}" = "1" ]]; then
|
|||
S_NEXTITEM="2"
|
||||
return 1
|
||||
fi
|
||||
DIALOG --msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)" 0 0
|
||||
DIALOG --cr-wrap --msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n${DATE_PROGRAM}" 0 0
|
||||
else
|
||||
# display and ask to set date/time
|
||||
CANCEL=""
|
||||
|
@ -113,11 +115,8 @@ if [[ "${SET_TIME}" = "1" ]]; then
|
|||
# save the time
|
||||
# DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss
|
||||
local _datetime="$(echo "${_date}" "${_time}" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\3-\2-\1 \4:\5:\6#g')"
|
||||
date -s "${_datetime}"
|
||||
DIALOG --infobox "Syncing systemclock to hardwareclock ..." 0 0
|
||||
HWCLOCK_PARAMS="--systohc"
|
||||
dohwclock
|
||||
DIALOG --msgbox "Your current time is now:\n$(date)" 0 0
|
||||
timedatectl set-time "${_datetime}"
|
||||
DIALOG --cr-wrap --msgbox "Your current time is now:\n${DATE_PROGRAM}" 0 0
|
||||
fi
|
||||
fi
|
||||
S_NEXTITEM="3"
|
||||
|
@ -159,17 +158,6 @@ if [[ ! -d ${BASEDIR} ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $(which hwclock) ]]; then
|
||||
echo "'hwclock' binary not found!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [[ ! $(which date) ]]; then
|
||||
echo "'date' binary not found!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -e /tmp/.tz-running ]]; then
|
||||
echo "tz already runs on a different console!"
|
||||
echo "Please remove /tmp/.tz-running first to launch tz!"
|
||||
|
|
Loading…
Reference in a new issue