ClangBuiltLinux / boot-utils

Collection of files for booting Linux kernels
26 stars 7 forks source link

overlay: Exit rcS script so it only runs once #41

Closed shenki closed 3 years ago

shenki commented 3 years ago

Ever wondered why the /proc/version output appears in the logs twice?

I discovered that if we exit from the scripts instead of doing nothing, it only appears once! I could speculate what's going on but I don't precisely know.

Signed-off-by: Joel Stanley joel@jms.id.au

shenki commented 3 years ago

I don't have a cbl setup at the moment to fully test., but I did test locally in my buildroot environment.

nathanchance commented 3 years ago

Actually, it looks like this is because init.d has two different actions, start and stop, which you can see by adding an echo $* above cat /proc/version.

This should fix it:

diff --git a/buildroot/overlay-poweroff/etc/init.d/S50yolo b/buildroot/overlay-poweroff/etc/init.d/S50yolo
index 2b06371..0499d71 100755
--- a/buildroot/overlay-poweroff/etc/init.d/S50yolo
+++ b/buildroot/overlay-poweroff/etc/init.d/S50yolo
@@ -1,4 +1,6 @@
 #!/bin/sh

-cat /proc/version
-poweroff
+if [ "$1" = "start" ]; then
+    cat /proc/version
+    poweroff
+fi
diff --git a/buildroot/overlay-reboot/etc/init.d/S50yolo b/buildroot/overlay-reboot/etc/init.d/S50yolo
index ed0203b..0bc3e46 100755
--- a/buildroot/overlay-reboot/etc/init.d/S50yolo
+++ b/buildroot/overlay-reboot/etc/init.d/S50yolo
@@ -1,4 +1,6 @@
 #!/bin/sh

-cat /proc/version
-reboot
+if [ "$1" = "start" ]; then
+    cat /proc/version
+    reboot
+fi
shenki commented 3 years ago

Even better! Feel free to push your change instead of mine