diff options
author | Jonathan Bauer | 2019-01-09 13:06:52 +0100 |
---|---|---|
committer | Jonathan Bauer | 2019-01-09 13:06:52 +0100 |
commit | 442f1bdfd0cbfdc10f484584c26940384e8352fe (patch) | |
tree | 747f50ec881d461fe2879ca14ce4a0081ae87582 /builder/modules.d/slx-clock | |
parent | [dnbd3-rfs] remove deprecated script (diff) | |
download | systemd-init-442f1bdfd0cbfdc10f484584c26940384e8352fe.tar.gz systemd-init-442f1bdfd0cbfdc10f484584c26940384e8352fe.tar.xz systemd-init-442f1bdfd0cbfdc10f484584c26940384e8352fe.zip |
[slx-clock] new module for time-related stuff
evaluates SLX_BIOS_CLOCK and SLX_NTP_SERVER from the openslx config.
Diffstat (limited to 'builder/modules.d/slx-clock')
-rwxr-xr-x | builder/modules.d/slx-clock/module-setup.sh | 13 | ||||
-rw-r--r-- | builder/modules.d/slx-clock/scripts/configure-timesyncd.sh | 32 |
2 files changed, 45 insertions, 0 deletions
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 |