From 9b49d6aacd554cd990c87b63de1221328bbcdb81 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 17 Oct 2023 10:31:09 +0200 Subject: [PATCH] Even more alpine fixes (#492) --- .../kairos-overlay-files/collection.yaml | 2 +- .../files/system/oem/10_accounting.yaml | 3 +++ .../files/system/oem/25_autologin.yaml | 17 ++++++++++++- .../files/system/oem/28_cgroups.yaml | 7 ------ .../files/system/oem/50_recovery.yaml | 12 ++++------ .../files/system/oem/51_reset.yaml | 14 ++++------- .../files/system/oem/52_installer.yaml | 24 ++++++++++--------- 7 files changed, 43 insertions(+), 36 deletions(-) delete mode 100644 packages/static/kairos-overlay-files/files/system/oem/28_cgroups.yaml diff --git a/packages/static/kairos-overlay-files/collection.yaml b/packages/static/kairos-overlay-files/collection.yaml index 7c5ba95..aa7d469 100644 --- a/packages/static/kairos-overlay-files/collection.yaml +++ b/packages/static/kairos-overlay-files/collection.yaml @@ -1,4 +1,4 @@ packages: - name: "kairos-overlay-files" category: "static" - version: "1.1.2" + version: "1.1.3" diff --git a/packages/static/kairos-overlay-files/files/system/oem/10_accounting.yaml b/packages/static/kairos-overlay-files/files/system/oem/10_accounting.yaml index 3d915fb..8d5287d 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/10_accounting.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/10_accounting.yaml @@ -48,6 +48,9 @@ stages: commands: - chown -R root:admin /usr/local/cloud-config - chmod 770 /usr/local/cloud-config + initramfs.after: + # Run this in the after stage so it doesnt collide with other initramfs changes to the /etc/inittab + # Otherwise this can lead to 2 steps modifying the inittab at the same time and overriding or not cleaning it properly - name: "Enable serial login for alpine" # https://wiki.alpinelinux.org/wiki/Enable_Serial_Console_on_Boot if: '[ -e /sbin/openrc ]' commands: diff --git a/packages/static/kairos-overlay-files/files/system/oem/25_autologin.yaml b/packages/static/kairos-overlay-files/files/system/oem/25_autologin.yaml index 2717027..76167c1 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/25_autologin.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/25_autologin.yaml @@ -2,7 +2,7 @@ name: "Root autologin" stages: initramfs: - if: | - [ ! $(cat /proc/cmdline | grep -q "interactive-install") ] && \ + grep -qv "interactive-install" /proc/cmdline && \ [ -f /run/cos/live_mode ] && \ ( [ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] ) files: @@ -18,3 +18,18 @@ stages: ExecStart= ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM permissions: 0644 + - name: "Autologin on livecd for OpenRC" + if: | + grep -qv "interactive-install" /proc/cmdline ] && \ + [ -f /run/cos/live_mode ] && \ + [ -f "/sbin/openrc" ] + files: + - path: /etc/motd + content: | + You are booting from livecd mode. Run 'kairos-agent install' to install the system. + permissions: 0644 + - path: /etc/inittab + content: | + tty1::respawn:/sbin/agetty --autologin root -i --noclear tty1 + ttyS0::respawn:/sbin/agetty --autologin root -i --noclear ttyS0 + permissions: 0644 \ No newline at end of file diff --git a/packages/static/kairos-overlay-files/files/system/oem/28_cgroups.yaml b/packages/static/kairos-overlay-files/files/system/oem/28_cgroups.yaml deleted file mode 100644 index 2c1b6e8..0000000 --- a/packages/static/kairos-overlay-files/files/system/oem/28_cgroups.yaml +++ /dev/null @@ -1,7 +0,0 @@ -stages: - initramfs.before: - - name: "Setup hybrid cgroups" - if: '[ -e /etc/rc.conf ]' - commands: - - echo 'rc_cgroup_mode="hybrid"' >> /etc/rc.conf - - echo 'rc_cgroup_controllers="cpuset cpu io memory hugetlb pids"' >> /etc/rc.conf diff --git a/packages/static/kairos-overlay-files/files/system/oem/50_recovery.yaml b/packages/static/kairos-overlay-files/files/system/oem/50_recovery.yaml index d142483..1f0796e 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/50_recovery.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/50_recovery.yaml @@ -3,18 +3,16 @@ stages: initramfs: - name: "Starts kairos-recovery and generate a temporary pass" if: | - cat /proc/cmdline | grep -q "kairos.remote_recovery_mode" + grep -q "kairos.remote_recovery_mode" /proc/cmdline && \ + ( [ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] ) commands: - systemctl disable getty@tty1 - systemctl enable kairos-recovery - # Starts installer on boot in Alpine and openRC based - - name: "Starts kairos-recovery with openRC-based systems" - if: | - [ -f "/etc/inittab" ] && \ - ( cat /proc/cmdline | grep -q "kairos.remote_recovery_mode" ) + - name: "Starts kairos-recovery for openRC based systems" + if: grep -q "kairos.remote_recovery_mode" /proc/cmdline && [ -f "/sbin/openrc" ] commands: - sed -i -e 's/tty1.*//g' /etc/inittab - - echo "tty1::respawn:/usr/bin/kairos-agent recovery" >> /etc/inittab + - echo "tty1::respawn:/usr/bin/kairos-agent recovery tty1" >> /etc/inittab boot: - name: "Recovery" if: '[ -f "/run/cos/recovery_mode" ]' diff --git a/packages/static/kairos-overlay-files/files/system/oem/51_reset.yaml b/packages/static/kairos-overlay-files/files/system/oem/51_reset.yaml index 55700f7..12c3bb5 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/51_reset.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/51_reset.yaml @@ -1,17 +1,13 @@ name: "Start reset on tty1" stages: initramfs: - - name: "Starts kairos-reset" - if: | - cat /proc/cmdline | grep -q "kairos.reset" + - name: "Starts kairos-reset for systemd based systems" + if: grep -q "kairos.reset" /proc/cmdline && [ ! -f "/sbin/openrc" ] commands: - systemctl disable getty@tty1 - systemctl enable kairos-reset - # Starts installer on boot in Alpine and openRC based - - name: "Starts kairos-reset with openRC-based systems" - if: | - [ -f "/etc/inittab" ] && \ - ( cat /proc/cmdline | grep -q "kairos.reset" ) + - name: "Starts kairos-reset for openRC-based systems" + if: grep -q "kairos.reset" /proc/cmdline && [ -f "/sbin/openrc" ] commands: - sed -i -e 's/tty1.*//g' /etc/inittab - - echo "tty1::respawn:/usr/bin/kairos-agent reset" >> /etc/inittab + - echo "tty1::respawn:/usr/bin/kairos-agent reset tty1" >> /etc/inittab diff --git a/packages/static/kairos-overlay-files/files/system/oem/52_installer.yaml b/packages/static/kairos-overlay-files/files/system/oem/52_installer.yaml index e89e4ea..45493c3 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/52_installer.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/52_installer.yaml @@ -2,34 +2,36 @@ name: "Start installer on tty1" stages: initramfs: - if: | - cat /proc/cmdline | grep -q "nodepair.enable" + grep -q "nodepair.enable" /proc/cmdline && \ + ( [ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] ) commands: - systemctl disable getty@tty1 - systemctl enable kairos - systemctl enable kairos-webui - # Starts installer on boot in Alpine and openRC based - - if: | - cat /proc/cmdline | grep -q "nodepair.enable" + # Starts installer on boot for openRC based systems + - if: grep -q "nodepair.enable" /proc/cmdline && [ -f "/sbin/openrc" ] commands: - sed -i -e 's/tty1.*//g' /etc/inittab - - echo "tty1::respawn:/usr/bin/kairos-agent install" >> /etc/inittab + - echo "tty1::respawn:/usr/bin/kairos-agent install tty1" >> /etc/inittab + # Starts installer on boot for systemd based systems - if: | - cat /proc/cmdline | grep -q "interactive-install" + grep -q "interactive-install" /proc/cmdline && \ + ( [ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] ) commands: - systemctl disable getty@tty1 - systemctl enable kairos-interactive - # Starts installer on boot in Alpine and openRC based - - if: | - cat /proc/cmdline | grep -q "interactive-install" + # Starts installer on boot for openRC based systems + - if: grep -q "interactive-install" /proc/cmdline && [ -f "/sbin/openrc" ] commands: - sed -i -e 's/tty1.*//g' /etc/inittab - - echo "tty1::respawn:/usr/bin/kairos-agent interactive-install --shell" >> /etc/inittab + - echo "tty1::respawn:/usr/bin/kairos-agent interactive-install --shell tty1" >> /etc/inittab boot: - if: | [ "$(kairos-agent state get boot)" == "livecd_boot" ] && [ -f "/sbin/rc-service" ] commands: - rc-service kairos-webui start - if: | - [ "$(kairos-agent state get boot)" == "livecd_boot" ] && [ -d "/usr/share/systemd" ] + [ "$(kairos-agent state get boot)" == "livecd_boot" ] && \ + ( [ -e "/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ] ) commands: - systemctl start kairos-webui