Skip to content

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

Closed
shenki wants to merge 1 commit into
ClangBuiltLinux:mainfrom
shenki:just-once-thanks
Closed

overlay: Exit rcS script so it only runs once#41
shenki wants to merge 1 commit into
ClangBuiltLinux:mainfrom
shenki:just-once-thanks

Conversation

@shenki

@shenki shenki commented Mar 30, 2021

Copy link
Copy Markdown
Member

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

shenki commented Mar 30, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

shenki commented Apr 6, 2021

Copy link
Copy Markdown
Member Author

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.

2 participants