Jens Persson escribió:
> Ismael Luceno wrote:
>> Jens Persson escribió:
>>   
>>> Hello folks.
>>>
>>> Taken from IRC:
>>>
>>> <ismaell> hi again qupada
>>> <ismaell> i was thinking about service_file...
>>> <ismaell> when you define a service like in system/getty
>>> <ismaell> there's no problem, because you want system/agetty/*
>>> <ismaell> but when it's a single service, if you don't specify the service
>>> <ismaell> and you try to load, service/some/weird/thing
>>> <ismaell> it will register it :(
>>> <ismaell> that's dangerous...
>>> <qupada> i was under the impression it would just fail with a 
>>> 'NOT_FOUND' error
>>> <qupada> in rather the same manner that it does at the moment
>>> <ismaell> if you don't use the "-s" param., setup() defines whatever is 
>>> in $SERVICE :(
>>> <ismaell> the solution is simple
>>> <qupada> $ ngc -u daemon/some/shit/i/made/up initNGControl (0.6.9-svn ) 
>>> by Jimmy Wennlund http://www.initng.org/
>>> <qupada> Service "daemon/some/shit/i/made/up" previously failed (NOT_FOUND),
>>> <qupada> it needs to be zaped "ngc -z daemon/some/shit/i/made/up", so 
>>> initng will forget the failing state before you are able to retry start it.
>>> <qupada> what's the problem with that behaviour?
>>> <ismaell> no no, that's not what i mean.
>>> <ismaell> look at system/clock.s
>>> <qupada> well then i'm afraid i don't have the faintest idea what you're 
>>> talking about
>>> <ismaell> if you use it in your system
>>> <ismaell> and you try to start system/clock/something, it will register 
>>> and start it :(
>>>
>>> I thought that if you are not specifying anything it will just use tho 
>>> path instead, like "system/clock" in the example above.
>>> So: iregister service <=> iregister -s "system/clock" service
>>> Or am I missing a point here?
>>>     
>> No it uses $SERVICE, that is set by the service_file plugin.
>>
>> Example: when the plugin searchs for system/udev/filldev, it sets
>> $SERVICE to that, then splits the name, and starts the search adding
>> one element at a time, until it finds <INITNG_ROOT>/system/udev, then
>> it executes it.
>>
>> runiscript takes care of setting $SERVICE from the path
>> _if it is not set_, then it sets $NAME. After everything is set up it
>> calls the wrapper script.
>>
>> So I think that what we need is a function like the following:
>>
>> isservice()
>> {
>>      while [ "${#}" -gt 0 ]; do
>>              [ "${SERVICE}" = "${1}" ] && return 0
>>              shift
>>      done
>>      return 1
>> }
>>
>> So we can use it like:
>>
>> isservice system/udev/{filldev,udevd,mountdev} || exit 1
>>
>> or
>>
>> if isservice system/agetty; then
>>      ...
>>      exit 0
>> fi
>> ..
> Yes i think that's exactly what I meant.  So if the name is not set with 
> -s it should be set to $SERVICE_PATH and not to $NAME. We must keep such 
s/SERVICE_PATH/SERVICE_FILE/
s/NAME/SERVICE/

> dirty hacks outside of the scripts, no.
> 

OK, i agree, that's not nice.

There's another way, but i had to check the code to be sure it was
implemented...

The other thing we can do is to check for success at the first attempt
to register something, that way we avoid the problem of trying to
register something more than once, but we still need to set $SERVICE.
We can provide a function for that (we will put this kind of functions
in the wrappers), that way it will look better:

ireg()
{
        export SERVICE="${2}"
        iregister "${1}" || exit 1
}

So the scripts will look like:

setup()
{
        ireg service service/some_service
        iset need = system/bootmisc
        iexec start
        idone
}


btw, the $NAME variable isn't set correctly, imo:

$SERVICE = system/udev/udevd -> NAME = udevd (OK)
$SERVICE = system/udev -> $NAME = udev (it should be '')
$SERVICE = system/udev/some/other -> $NAME = other
(it should be 'some/other')

I will try to find some efficient fix.


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng

Reply via email to