Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

shenki
Copy link
Member

@shenki shenki commented Mar 30, 2021

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

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
Copy link
Member Author

shenki commented Mar 30, 2021

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

@nathanchance
Copy link
Member

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
Copy link
Member Author

shenki commented Apr 6, 2021

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

nathanchance added a commit to nathanchance/boot-utils that referenced this pull request Apr 7, 2021
Currently, when booting the images, the version string prints out twice.
This is because these scripts are called twice: once with the "start"
action and again with the "stop" action.

To avoid this, just run the contents of the script when the service is
starting.

Closes: ClangBuiltLinux#41

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@msfjarvis msfjarvis closed this in #42 Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants