Fix #588: Add chrony ntp client & timezone config (#674)

This adds chrony as the ntp client (starting on boot), and also adds a
prompt in the init step for configuring the timezone.
This commit is contained in:
clayton craft 2017-10-13 19:18:24 +00:00 committed by Oliver Smith
parent 9f0c884188
commit 816cc9f625
5 changed files with 41 additions and 3 deletions

View File

@ -1,12 +1,13 @@
pkgname=postmarketos-base
pkgver=3
pkgrel=8
pkgrel=9
pkgdesc="Meta package for minimal postmarketOS base"
url="https://github.com/postmarketOS"
arch="noarch"
license="GPL3+"
depends="
alpine-base
chrony
cryptsetup
eudev
haveged
@ -67,4 +68,4 @@ sha512sums="38dc75c0ed32b76dccd3d8e7e8173e8b7d91847cf2b07123f376b95af46b4f89798b
3ceeee37f558e7c95ad973692b6a437f997e6b46c3d1c2257ddfb1529a5633477373aa123c7f08164e818daae50acb203d151379f27ca11bd458809e6a0d4de7 swapfile
f5cc0f1265955d2646e5f099dd4b5d4c287945bfc18c16044db57670d456f55c678fc11cc59e6dab3fa340832ce869d516302a3a35c13518539ed0cedca51819 swapfile.init
e0d2d48b82a03239a4c0a00acaf83e00d397c23a8d7c71053d4e2a383357c22dcedef9e81b0e12a1d7514e1fdbe0bb3eb82613d18b29034a7ce5447f13c84a53 swapfile.conf
4f00ad8ce8533fb884b083c094adada26ef845718a229e3ae94986997997297d9bec073babbe8829c29d28aaf31a01ebf28c041395ae7d8631be574b88059e34 postmarketos-base.post-install"
2550a40f44e593bd6c2fafcf27464470d0cc97b1de9ad712c4a167b3ae6cef015a8ba9249176e446bb7852c0d881d3f02a9eba60f4ac655462bc4016026e51e6 postmarketos-base.post-install"

View File

@ -13,7 +13,7 @@ done
for service in hwclock modules sysctl hostname bootmisc swclock syslog; do
rc-update -q add $service boot
done
for service in dbus haveged sshd swapfile wpa_supplicant; do
for service in dbus haveged sshd swapfile wpa_supplicant chronyd; do
rc-update -q add $service default
done
for service in mount-ro killprocs savecache; do
@ -76,3 +76,8 @@ sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
# Add user to video group for proper framebuffer permissions
username="$(getent passwd 1000 | cut -d ":" -f 1)"
usermod -a -G video "$username"
# Set chrony to quickly correct system time on first boot, if necessary
if ! grep -q "makestep" /etc/chrony/chrony.conf; then
echo "makestep 1 -1" >> /etc/chrony/chrony.conf
fi

View File

@ -63,6 +63,7 @@ defaults = {
"ui": "weston",
"user": "user",
"keymap": "",
"timezone": "GMT",
# aes-xts-plain64 would be better, but this is not supported on LineageOS
# kernel configs

View File

@ -23,6 +23,7 @@ import os
import pmb.config
import pmb.helpers.cli
import pmb.helpers.devices
import pmb.helpers.run
import pmb.helpers.ui
import pmb.chroot.zap
import pmb.parse.deviceinfo
@ -86,6 +87,30 @@ def ask_for_keymaps(args, device):
" one from the list above.")
def ask_for_timezone(args):
localtimes = ["/etc/zoneinfo/localtime", "/etc/localtime"]
zoneinfo_path = "/usr/share/zoneinfo/"
for localtime in localtimes:
if not os.path.exists(localtime):
continue
tz = ""
if os.path.exists(localtime):
tzpath = os.path.realpath(localtime)
tzpath = tzpath.rstrip()
if os.path.exists(tzpath):
try:
_, tz = tzpath.split(zoneinfo_path)
except:
pass
if tz:
logging.info("Your host timezone: " + tz)
if pmb.helpers.cli.confirm(args, "Use this timezone instead of GMT?",
default="y"):
return tz
logging.info("WARNING: Unable to determine timezone configuration on host, using GMT.")
return "GMT"
def init(args):
cfg = pmb.config.load(args)
@ -134,6 +159,9 @@ def init(args):
None, args.extra_packages,
validation_regex="^(|[-.+\w\s]+(?:,[-.+\w\s]*)*)$")
# Configure timezone info
cfg["pmbootstrap"]["timezone"] = ask_for_timezone(args)
# Do not save aports location to config file
del cfg["pmbootstrap"]["aports"]

View File

@ -310,6 +310,9 @@ def install(args):
# Set the keymap if the device requires it
setup_keymap(args)
# Set timezone
pmb.chroot.root(args, ["setup-timezone", "-z", args.timezone], suffix)
if args.android_recovery_zip:
install_recovery_zip(args)
else: