From 291657012c0eb9cc2d37d8b607209ec9bba01363 2018-12-17 16:00:18 From: Yannick Schinko Date: 2018-12-17 16:00:18 Subject: [PATCH] Reordered firstboot script - Also removed restarting of `dphys-swapfile` in expandroot.sh --- diff --git a/bootstrap.d/50-firstboot.sh b/bootstrap.d/50-firstboot.sh index 57331ca..1b17876 100644 --- a/bootstrap.d/50-firstboot.sh +++ b/bootstrap.d/50-firstboot.sh @@ -8,24 +8,24 @@ # Prepare rc.firstboot script cat files/firstboot/10-begin.sh > "${ETC_DIR}/rc.firstboot" -# Ensure openssh server host keys are regenerated on first boot -if [ "$ENABLE_SSHD" = true ] ; then - cat files/firstboot/20-generate-ssh-keys.sh >> "${ETC_DIR}/rc.firstboot" -fi - # Prepare filesystem auto expand if [ "$EXPANDROOT" = true ] ; then if [ "$ENABLE_CRYPTFS" = false ] ; then - cat files/firstboot/30-expandroot.sh >> "${ETC_DIR}/rc.firstboot" - - # Restart dphys-swapfile so the size of the swap file is relative to the resized root partition - if [ "$ENABLE_DPHYSSWAP" = true ] ; then - cat files/firstboot/31-restart-dphys-swapfile.sh >> "${ETC_DIR}/rc.firstboot" - fi + cat files/firstboot/20-expandroot.sh >> "${ETC_DIR}/rc.firstboot" else # Regenerate initramfs to remove encrypted root partition auto expand - cat files/firstboot/33-regenerate-initramfs.sh >> "${ETC_DIR}/rc.firstboot" + cat files/firstboot/21-regenerate-initramfs.sh >> "${ETC_DIR}/rc.firstboot" fi + + # Restart dphys-swapfile so the size of the swap file is relative to the resized root partition + if [ "$ENABLE_DPHYSSWAP" = true ] ; then + cat files/firstboot/23-restart-dphys-swapfile.sh >> "${ETC_DIR}/rc.firstboot" + fi +fi + +# Ensure openssh server host keys are regenerated on first boot +if [ "$ENABLE_SSHD" = true ] ; then + cat files/firstboot/30-generate-ssh-keys.sh >> "${ETC_DIR}/rc.firstboot" fi # Ensure that dbus machine-id exists diff --git a/files/firstboot/30-expandroot.sh b/files/firstboot/20-expandroot.sh similarity index 95% rename from files/firstboot/30-expandroot.sh rename to files/firstboot/20-expandroot.sh index c2590a2..235c411 100644 --- a/files/firstboot/30-expandroot.sh +++ b/files/firstboot/20-expandroot.sh @@ -66,11 +66,3 @@ EOF2 partprobe && resize2fs /dev/${ROOT_PART} && logger -t "rc.firstboot" "Root partition successfully resized." - -# Restart dphys-swapfile service if it exists -if systemctl list-units | grep -q dphys-swapfile ; then - if systemctl is-enabled dphys-swapfile ; then - logger -t "rc.firstboot" "Restarting dphys-swapfile" - systemctl restart dphys-swapfile - fi -fi diff --git a/files/firstboot/33-regenerate-initramfs.sh b/files/firstboot/21-regenerate-initramfs.sh similarity index 100% rename from files/firstboot/33-regenerate-initramfs.sh rename to files/firstboot/21-regenerate-initramfs.sh diff --git a/files/firstboot/31-restart-dphys-swapfile.sh b/files/firstboot/23-restart-dphys-swapfile.sh similarity index 60% rename from files/firstboot/31-restart-dphys-swapfile.sh rename to files/firstboot/23-restart-dphys-swapfile.sh index ad0c3a0..9f9d742 100644 --- a/files/firstboot/31-restart-dphys-swapfile.sh +++ b/files/firstboot/23-restart-dphys-swapfile.sh @@ -1,5 +1,7 @@ -logger -t "rc.firstboot" "Restarting dphys-swapfile" +# Restart dphys-swapfile service if it exists +if systemctl list-units | grep -q dphys-swapfile ; then + logger -t "rc.firstboot" "Restarting dphys-swapfile" -if systemctl is-enabled dphys-swapfile ; then + systemctl enable dphys-swapfile systemctl restart dphys-swapfile fi diff --git a/files/firstboot/20-generate-ssh-keys.sh b/files/firstboot/30-generate-ssh-keys.sh similarity index 100% rename from files/firstboot/20-generate-ssh-keys.sh rename to files/firstboot/30-generate-ssh-keys.sh