Hi Eric,
I had a similar problem. I wanted to give the ability for a
serially-connected user to press ENTER to stay in busybox. The comments
below should be self explanatory, but here's the gist. Put a sleeping
process into the background. If the sleeping processes times out, then
kill the shell. When the shell exists, there'll be a boot into full
Debian. If the user hits ENTER, then the /shinit script kills the
sleeping process, thereby preventing the full boot. It's really just a
matter of who kills whom first. :-)
The script below is a modified /shinit from the busybox root directory.
Don't forget to do a 'save' before trying it out!
I hope that you can modify the script to suit your needs.
-Frank
============================= Contents of /shinit
==============================
. /ts7800.subr
timeout=10
# Put a sleep and kill in the background.
# If this subprocess doesn't get killed within
# the allotted time, then the subprocess will
# itself kill the parent shell, and the TS board
# will boot to full Debian.
(
sleep $timeout
kill -9 $$
) &
sleeper=$!
case $- in *i*)
stty ospeed 115200 >/dev/null 2>&1
echo "Finished booting in $BOOTTIME seconds"
echo "Type 'tshelp' for help"
echo ""
esac
echo "Will autoboot to card in $timeout seconds."
read -p "Press ENTER to stay in busybox: " ans
echo
# If the user hits ENTER within the 'timeout' value,
# kill the sleeper process so busybox won't be killed.
kill -9 $sleeper
eric.robishaw wrote:
>
>
> I have a script that runs on startup of busybox on the SD card.
>
> I need to allow the user to abort the script...
>
> i.e., :
> "Press a key in the next 10 seconds to abort this script"
> A timed-out Read (read -t 10) would be ideal but that's not supported
> in busybox linux.
>
> I'd be happy with "Press Control-C to abort this script"
> but Ctrl-C doesn't stop the script. Even tried to trap it:
>
> trap bashtrap INT
> bashtrap()
> {
> exit
> }
>
> But that doesn't work either.
>
> The script is being executed in linuxrc-sdroot:
> /lbin/tsinitnfs < $CONSOLE > $CONSOLE
>
> Any ideas?
>
> __._
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|