sysvinit: start .sh scripts correctly
cover sysvinit: start .sh scripts correctly
From: Chen Qi <[email protected]>
The following changes since commit e96d541c8edccbb69602eace900ce9293ee12d22:
tiny-init: Mount devtmpfs manually (2013-02-22 06:39:07 -0800)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/sysv-consistent
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/sysv-consistent
Chen Qi (1):
sysvinit: start .sh scripts correctly
meta/recipes-core/sysvinit/sysvinit/rc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/1 sysvinit: start .sh scripts correctly
From: Chen Qi <[email protected]>
Previously, scripts which end with '.sh' were sourced, so the arguments like 'start' and 'stop' were just ignored.
This resulted in some init scripts not being able to start correctly. For example, sourcing hwclock.sh in busybox actually does nothing. It should be invoked as 'hwclock.sh start' or 'hwclock.sh stop'.
This patch fixes this issue.
[YOCTO #3612]
--- meta/recipes-core/sysvinit/sysvinit/rc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
meta/recipes-core/sysvinit/sysvinit/rc +1 -15
@@ -41,21 +41,7 @@ startup_progress() { startup() { # Handle verbosity [ "$VERBOSE" = very ] && echo "INIT: Running $@..." - - case "$1" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - scriptname=$1 - shift - . $scriptname - ) - ;; - *) - "$@" - ;; - esac + "$@" startup_progress }
Signature · 1 line
1.7.9.5
Quoted 23 lines · On 02/25/2013 05:39 PM, [email protected] wrote:
From: Chen Qi <[email protected]>
Previously, scripts which end with '.sh' were sourced, so the arguments like 'start' and 'stop' were just ignored.
This resulted in some init scripts not being able to start correctly. For example, sourcing
hwclock.shin busybox actually does nothing. It should be invoked as 'hwclock.shstart' or 'hwclock.shstop'.This patch fixes this issue.
[YOCTO #3612]
Signed-off-by Chen Qi <[email protected]>--- meta/recipes-core/sysvinit/sysvinit/rc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)meta/recipes-core/sysvinit/sysvinit/rc +0
-0
meta/recipes-core/sysvinit/sysvinit/rc startup_progress() { · line 49
Quoted 9 lines
meta/recipes-core/sysvinit/sysvinit/rc +0
-6@@ -41,21 +41,7 @@ startup_progress() { startup() { # Handle verbosity [ "$VERBOSE" = very ] && echo "INIT: Running $@..." - - case "$1" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP
Are you sure you don't want the trap still? I realize this reset it to default..
Sau!
Quoted 14 lines
meta/recipes-core/sysvinit/sysvinit/rc +1
-9- scriptname=$1 - shift - . $scriptname - ) - ;; - *) - "$@" - ;; - esac + "$@" startup_progress }
Quoted 19 lines · Saul Wold
Quoted 18 lines · On 02/25/2013 05:39 PM, [email protected] wrote:
From: Chen Qi <[email protected]>
Previously, scripts which end with '.sh' were sourced, so the arguments like 'start' and 'stop' were just ignored.
This resulted in some init scripts not being able to start correctly. For example, sourcing
hwclock.shin busybox actually does nothing. It should be invoked as 'hwclock.shstart' or 'hwclock.shstop'.This patch fixes this issue.
[YOCTO #3612]
Signed-off-by Chen Qi <[email protected]>--- meta/recipes-core/sysvinit/sysvinit/rc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
Quoted 17 lines
Quoted 5 lines
meta/recipes-core/sysvinit/sysvinit/rc +0
-0meta/recipes-core/sysvinit/sysvinit/rc startup_progress() { · line 49
Quoted 9 lines
meta/recipes-core/sysvinit/sysvinit/rc +0
-6@@ -41,21 +41,7 @@ startup_progress() { startup() { # Handle verbosity [ "$VERBOSE" = very ] && echo "INIT: Running $@..." - - case "$1" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTPAre you sure you don't want the trap still? I realize this reset it to default..
Yes.
Code snippet from rc:
# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. trap ":" INT QUIT TSTP
So these signals are ignored in rc but passed on to subprocesses. And the reset is not needed.
If in rc we use
trap "" INIT QUIT TSTP
then the reset is needed.
Best Regards,
Chen Qi
Quoted 18 lines
Sau!
Quoted 14 lines
meta/recipes-core/sysvinit/sysvinit/rc +1
-9- scriptname=$1 - shift - . $scriptname - ) - ;; - *) - "$@" - ;; - esac + "$@" startup_progress }
Burton, Ross
NAKQuoted 8 lines · On 26 February 2013 01:39, <[email protected]> wrote:
meta/recipes-core/sysvinit/sysvinit/rc +0
-8- - case "$1" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - scriptname=$1 - shift
meta/recipes-core/sysvinit/sysvinit/rc startup_progress() { · line 46
Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit/rc +1
-7- . $scriptname - ) - ;; - *) - "$@" - ;; - esac + "$@" startup_progress }
NACK.
By "fix" you mean "remove the tested and proven optimisation"? The "if .sh use ." test was designed to speed up booting by not forking a new bash, and it's been demonstrated to have a noticeable difference on slower hardware.
You can pass arguments to "." as this little test demonstrates:
$ cat service.sh echo My arguments are "$@" $ . service.sh foo bar My arguments are foo bar
The "shift" command shows that passing the arguments to the script was the intention, and a few lines of micro-test demonstrate that it *should* work:
$ cat rc.sh
startup() {
scriptname=$1
shift
. $scriptname
}
startup ./service.sh start
$ busybox sh ./rc.sh
My arguments are startSo, something else is going wrong.
Ross
Quoted 47 lines · Ross
Quoted 8 lines · On 26 February 2013 01:39, <[email protected]> wrote:
meta/recipes-core/sysvinit/sysvinit/rc +0
-8- - case "$1" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - scriptname=$1 - shiftmeta/recipes-core/sysvinit/sysvinit/rc startup_progress() { · line 46
Quoted 10 lines
meta/recipes-core/sysvinit/sysvinit/rc +1
-7- . $scriptname - ) - ;; - *) - "$@" - ;; - esac + "$@" startup_progress }NACK.
By "fix" you mean "remove the tested and proven optimisation"? The "if .sh use ." test was designed to speed up booting by not forking a new bash, and it's been demonstrated to have a noticeable difference on slower hardware.
You can pass arguments to "." as this little test demonstrates:
$ cat service.sh echo My arguments are "$@" $ . service.sh foo bar My arguments are foo barThe "shift" command shows that passing the arguments to the script was the intention, and a few lines of micro-test demonstrate that it *should* work:
$ cat rc.sh startup() { scriptname=$1 shift . $scriptname } startup ./service.sh start $ busybox sh ./rc.sh My arguments are start
Quoted 5 lines
So, something else is going wrong.
Ross
Yes, you're right.
I absolutely made a mistake.
Thank you for pointing it out.
Best Regards,
Chen Qi