Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 456650 - sys-apps/openrc - enhance /etc/local.d/README
Summary: sys-apps/openrc - enhance /etc/local.d/README
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 439098
  Show dependency tree
 
Reported: 2013-02-10 12:48 UTC by Toralf Förster
Modified: 2013-02-26 15:38 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2013-02-10 12:48:10 UTC
It should contain a sentence like :

Ensure, that every script exits soon - or - use a wrapper which calls something like "nohup <foo.sh> &".

OMHO.
Comment 1 William Hubbs gentoo-dev 2013-02-12 16:14:59 UTC
There are no restrictions on /etc/local.d, so I don't know what the
issue is you are trying to solve.

Thanks,

William
Comment 2 Toralf Förster gentoo-dev 2013-02-12 16:23:17 UTC
If a user puts in here a script which does not (immediately) exits - then all subsequent scripts aren't executed.

Here's an example :


n22 /etc/local.d # ls -l i915.start
-rwxr--r-- 1 root root 91 Feb 10 13:44 i915.start



n22 /etc/local.d # cat i915.start
#!/bin/sh
#

cd /tmp
nohup /home/tfoerste/workspace/bin/check_i915_error_state.sh &

exit




n22 /etc/local.d # cat /home/tfoerste/workspace/bin/check_i915_error_state.sh
#!/bin/sh
#

#       Toralf Foerster
#       Hamburg
#       Germany

# set -x

STATE=/sys/kernel/debug/dri/0/i915_error_state

while [[ : ]]
do
        LINES=$(wc -l $STATE | tail -n 1 | cut -f1 -d' ')
        if [[ $LINES -gt 1 ]]; then
                break
        fi

        sleep 30
done

DATE=$(date +%Y%m%d-%H%M%S)
FILE=/var/tmp/i915_error_state.${DATE}.txt.gz

gzip -c $STATE > $FILE
ls -l $FILE | mail -s "i915_error_state" tfoerste@localhost

exit 0
Comment 3 William Hubbs gentoo-dev 2013-02-12 16:42:30 UTC
(In reply to comment #2)
> If a user puts in here a script which does not (immediately) exits - then
> all subsequent scripts aren't executed.
> 
> Here's an example :
> 
> 
> n22 /etc/local.d # ls -l i915.start
> -rwxr--r-- 1 root root 91 Feb 10 13:44 i915.start
> 
> 
> 
> n22 /etc/local.d # cat i915.start
> #!/bin/sh
> #
> 
> cd /tmp
> nohup /home/tfoerste/workspace/bin/check_i915_error_state.sh &
> 
> exit

It looks like this exits right away, because it puts check_i915_error_state.sh in the background.
Comment 4 Toralf Förster gentoo-dev 2013-02-12 17:09:15 UTC
(In reply to comment #3)

> It looks like this exits right away, because it puts
> check_i915_error_state.sh in the background.

Right - and exactly this should be mentioned in the README.
Comment 5 William Hubbs gentoo-dev 2013-02-12 18:39:51 UTC
(In reply to comment #2)
> If a user puts in here a script which does not (immediately) exits - then
> all subsequent scripts aren't executed.

I'm not sure how this would be happening since the start() function in /etc/init.d/local does not fail if one of the scripts we run fails; it just moves on to the next one.

There is no intentional requirement that things run from local exit immediately. If you put something in local that takes an hour to run, we don't stop you from doing that, and the local service doesn't care about the return codes from whatever it runs, so I don't understand what you want me to put in the README.
Comment 6 Toralf Förster gentoo-dev 2013-02-12 18:52:26 UTC
ick - I could swear, that I didn't get a login prompt if those scripts doesn't return immediately - but now - you're right.

Closing this as a brain f...
Comment 7 Toralf Förster gentoo-dev 2013-02-14 20:45:32 UTC
I'm reopening this bug after testing it twice.

If you put the following script into /etc/local.d :

#!/bin/sh
#

FILE=/var/lib/boinc/stderrdae.txt

while [[ true ]]; do
        if [[ -s $FILE ]]; then
                cat $FILE | mail -s '$FILE' tfoerste@localhost
                break
        fi

        sleep 60
done

exit 0





then you'll never get a login prompt, as long as that file is empty.

And that's a good example, that a user shouldn't just symlink a script, isntad he has to write a wrapper for it.
Comment 8 William Hubbs gentoo-dev 2013-02-15 19:48:08 UTC
Ok, now I see what you are talking about. The local service does not
return until every process it is supposed to start or stop has been
started or stopped. So if something doesn't return, the local service
will wait forever for it to come back and you will not get a login
prompt.

I know that wording is confusing, but that's the idea. I will come up
with a better way to put it in the README.
Comment 9 SpanKY gentoo-dev 2013-02-19 06:55:41 UTC
(In reply to comment #8)

let's add a default timeout to the local init service.  people shouldn't be able to bugger their boot by accident like this.
Comment 10 Toralf Förster gentoo-dev 2013-02-19 09:25:39 UTC
(In reply to comment #9)
> (In reply to comment #8)
> 
> let's add a default timeout to the local init service.  people shouldn't be
> able to bugger their boot by accident like this.

What's about starting each script with "nohup ...&" and a (configurable ?) time intervall between each.
Comment 11 William Hubbs gentoo-dev 2013-02-20 17:30:26 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > 
> > let's add a default timeout to the local init service.  people shouldn't be
> > able to bugger their boot by accident like this.

@vapier:
What we would have to do is use the timeout command to force kill anything in local that runs for too long, and allow the timeout value to be configured. What is a good default timeout length? Would you say 60 seconds?

> What's about starting each script with "nohup ...&" and a (configurable ?)
> time intervall between each.

I think this isn't a good way to go because we have to deal with the redirection that nohup does and I'm not sure we want to ignore sighup.
Comment 12 William Hubbs gentoo-dev 2013-02-25 22:31:34 UTC
I updated the documentation as originally requested. I think that is the
more user-friendly option in this case; I don't think users would want
their processes to be killed because we thought they took too long.
The change is in commit ceb88fc and will be part of OpenRC-0.12.
Comment 13 Toralf Förster gentoo-dev 2013-02-26 15:38:08 UTC
(In reply to comment #12)
> I updated the documentation as originally requested.
:-D