diff options
| author | Denis Chevalier <perso@denischevalier.fr> | 2026-08-06 17:41:37 +0200 |
|---|---|---|
| committer | Denis Chevalier <perso@denischevalier.fr> | 2026-08-06 17:41:37 +0200 |
| commit | a63f7aa21b9fc26f7d0c1dd68e5d01fb1e26c7a8 (patch) | |
| tree | a1d625987fc735f89959dd6af14f3942f86e4623 | |
| parent | d396363099a88b892b58d408063c480a3991d78e (diff) | |
| download | postinstall-a63f7aa21b9fc26f7d0c1dd68e5d01fb1e26c7a8.tar.gz postinstall-a63f7aa21b9fc26f7d0c1dd68e5d01fb1e26c7a8.tar.bz2 postinstall-a63f7aa21b9fc26f7d0c1dd68e5d01fb1e26c7a8.zip | |
fix cmdline update to not overwrite root param
| -rw-r--r-- | etc/kernel/cmdline | 2 | ||||
| -rwxr-xr-x | setup.sh | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/etc/kernel/cmdline b/etc/kernel/cmdline index 0f92566..4a105f0 100644 --- a/etc/kernel/cmdline +++ b/etc/kernel/cmdline @@ -1 +1 @@ -root=PARTUUID=b7b36d6f-21ff-4f11-87a5-d07a84f4cc87 zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs init_on_alloc=1 init_on_free=1 slab_nomerge page_alloc.shuffle=1 vsyscall=none apparmor=1 lsm=landlock,lockdown,yama,integrity,apparmor,bpf audit=1 audit_backlog_limit=8192 quiet splash +init_on_alloc=1 init_on_free=1 slab_nomerge page_alloc.shuffle=1 vsyscall=none apparmor=1 lsm=landlock,lockdown,yama,integrity,apparmor,bpf audit=1 audit_backlog_limit=8192 @@ -84,7 +84,6 @@ sudo passwd -l root >/dev/null # Copy basic configuration files safely sudo cp -v ./etc/keyd/keyd.conf /etc/keyd/ sudo cp --backup=numbered -v ./etc/pacman.conf /etc/ -sudo cp --backup=numbered -v ./etc/kernel/cmdline /etc/kernel/ sudo cp -v ./etc/modprobe.d/blacklist-security.conf /etc/modprobe.d/ sudo cp -v ./etc/pam.d/system-local-login /etc/pam.d/ sudo cp -v ./etc/pam.d/system-login /etc/pam.d/ @@ -107,6 +106,33 @@ if [ -f "./etc/fstab" ]; then fi fi +# Append kernel command-line parameters before 'quiet splash' +EXTRA_PARAMS=$(tr '\n' ' ' < ./etc/kernel/cmdline | xargs) + +if [ -n "$EXTRA_PARAMS" ]; then + TARGET_CONTENT=$(cat /etc/kernel/cmdline) + + # Check if the extra parameters are already present to ensure idempotency + if [[ "$TARGET_CONTENT" != *"$EXTRA_PARAMS"* ]]; then + log_info "Inserting custom parameters into /etc/kernel/cmdline..." + + # Create a numbered backup before modifying + sudo cp --backup=numbered /etc/kernel/cmdline /etc/kernel/cmdline.bak + + if [[ "$TARGET_CONTENT" == *"quiet splash"* ]]; then + NEW_CMDLINE="${TARGET_CONTENT/quiet splash/$EXTRA_PARAMS quiet splash}" + else + # Fallback: append to the end if 'quiet splash' is not found + NEW_CMDLINE="${TARGET_CONTENT} ${EXTRA_PARAMS}" + fi + + # Normalize whitespace and save back to /etc/kernel/cmdline + echo "$NEW_CMDLINE" | xargs | sudo tee /etc/kernel/cmdline > /dev/null + else + log_info "Custom kernel parameters already present in /etc/kernel/cmdline. Skipping." + fi +fi + # Configure UFW Firewall log_info "Configuring UFW Firewall..." sudo ufw default deny incoming |
