Changes to contrib bootscripts

DJ Lucas dj at linuxfromscratch.org
Sat May 21 09:52:26 PDT 2011


On 05/21/2011 07:10 AM, Jeremy Huntwork wrote:
> On 5/21/11 2:48 AM, DJ Lucas wrote:
>> I do plan to add a "service" script later that would alleviate the issue
>> completely, as was suggested by Jeremy a few months ago, but I'm a
>> little stuck as far as how to handle multi-level, conditional tab
>> completions in bash, so it is on hold for a sec. Plus, I haven't seen
>> how Jeremy and Archaic handle that in LightCube OS yet. My simple
>> solution turned out to be not as simple as I had thought. That may even
>> turn out to be a C program included with initd-tools or somewhere
>> later...IDK as it hasn't been discussed yet. Jeremy, Archaic, any
>> ideas/suggestions on that?
> We've kept it simple, but possibly we have not met all the reqs:
>
> http://dev.lightcube.us/sources/lsb-bootscripts/service
>
> And then that's just installed to /usr/sbin:
>
> http://dev.lightcube.us/projects/lightcubeos/repository/entry/lightcube_os/trunk/packages/lsb-bootscripts/lsb-bootscripts.spec
>
Ok, cool. Thank you for the links. That was the direction I had headed. 
I got stuck with the bash completion though. Every time I try to use a 
second conditional for tab completion, those options of second functions 
in the event of -W, show in the first list. What I would like to do is 
use the value of $prev (in the example below) to set another variable 
that greps for "Usage:", sed out that and the brackets, and use IFS of 
"|" to display the options for the selected script. The example below is 
good enough to get a list of available scripts by typing "servi<tab><tab>"

#!/bin/bash
# Begin /etc/profile.d/service-completion.sh
#
#  service scriptname {start|stop|restart|reload|force-reload|status}
#

__service()
{
     local cur prev opts
     COMPREPLY=()
     cur="${COMP_WORDS[COMP_CWORD]}"
     prev="${COMP_WORDS[COMP_CWORD-1]}"
     opts="$(ls /etc/init.d | sed 's@/etc/init.d/@@')"
     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}

complete -F __service service

# End /etc/profile.d/service-completion.sh

While that is kind of cool IMO, I really do want it to spit out the 
script options as well. Prior to a few days ago, I had never explored 
the complete command.
>> 2nd, Jeremy's concern was the contents of rc.site. I agreed with all
>> suggestions, including combining lfs-fucntions with init-functions, save
>> one. I've made all the agreed changes locally. Most of everything in
>> rc.site has been moved into rc, with the exception of clock params,
>> hostname, conditional boot off/on and prompt time, boot logging off/on,
>> and the command that is run when a boot script ends in an unexpected
>> error ('read Enter' in our case). The last one I had just added and was
>> on the fence about, but after consideration, I've decided that to be
>> something that should be user configurable. Perhaps a function is best,
>> as I had suggested originally instead of putting a command in a variable
>> in a user configuration file. Make it configurable there by a simple
>> yes/no for PAUSE_ON_ERROR or some such.
> Sounds great. I can live with that.
Ok. I'll skip the easy way out. :-)
>> Theads got long quick, and a little OT at times, but I do believe that
>> is the remainder of the concerns.
> Are we treating the handling of network down logic as a separate issue?
> I think there was still some discussion out on that one.
Oh, I didn't realize that it had continued beyond the new network script 
and ifup/ifdown scripts, or rather I read it as just example, not an 
actual suggestion. Give me a few minutes to run through the thread again.
> JH

-- DJ Lucas


-- 
This message has been scanned for viruses and
dangerous content, and is believed to be clean.




More information about the lfs-dev mailing list