From 442f1bdfd0cbfdc10f484584c26940384e8352fe Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 9 Jan 2019 13:06:52 +0100 Subject: [slx-clock] new module for time-related stuff evaluates SLX_BIOS_CLOCK and SLX_NTP_SERVER from the openslx config. --- builder/modules.d/slx-clock/module-setup.sh | 13 +++++++++ .../slx-clock/scripts/configure-timesyncd.sh | 32 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 builder/modules.d/slx-clock/module-setup.sh create mode 100644 builder/modules.d/slx-clock/scripts/configure-timesyncd.sh diff --git a/builder/modules.d/slx-clock/module-setup.sh b/builder/modules.d/slx-clock/module-setup.sh new file mode 100755 index 00000000..50c36fe6 --- /dev/null +++ b/builder/modules.d/slx-clock/module-setup.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +check() { + # Tell dracut that this module should only be included if it is required + # explicitly. + return 255 +} +depends() { + echo dnbd3-rootfs +} +install() { + # unpacking config.tgz should be pre-pivot 10, let's do this afterwards + inst_hook pre-pivot 50 "$moddir/scripts/configure-timesyncd.sh" +} diff --git a/builder/modules.d/slx-clock/scripts/configure-timesyncd.sh b/builder/modules.d/slx-clock/scripts/configure-timesyncd.sh new file mode 100644 index 00000000..336c26bf --- /dev/null +++ b/builder/modules.d/slx-clock/scripts/configure-timesyncd.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# +# Evaluate SLX_BIOS_CLOCK and SLX_NTP_SERVER and configure +# stage4's timesyncd accordingly. + +. /etc/openslx + +configure_newroot_timesyncd() { + if [ "$SLX_BIOS_CLOCK" = "local" ]; then + cat > "$NEWROOT/etc/adjtime" <<-EOF + 0.0 0 0.0 + 0 + LOCAL + EOF + elif [ "$SLX_BIOS_CLOCK" = "utc" ]; then + [ -e "$NEWROOT/etc/adjtime" ] && rm "$NEWROOT/etc/adjtime" + fi + + # NTP servers + if [ -n "$SLX_NTP_SERVER" ]; then + local TIMESYNCD_DIR="$NEWROOT/etc/systemd/timesyncd.conf.d" + mkdir -p "$TIMESYNCD_DIR" + ( + echo "[Time]" + echo "NTP=$SLX_NTP_SERVER" + ) > "${TIMESYNCD_DIR}/00-slx.conf" + fi +} + +configure_newroot_timesyncd + +true -- cgit v1.2.3-55-g7522