[Initng] Register service in .s files
Jens Persson
xerxes2 at gmail.com
Sun Apr 1 05:45:19 CEST 2007
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
dirty hacks outside of the scripts, no.
More information about the Initng
mailing list