Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

/etc/init.dboot.local

32 views
Skip to first unread message

Cecil Westerhof

unread,
Oct 27, 2012, 5:41:23 PM10/27/12
to
I installed leafnode. With cron I fetch every hour the new articles.
Because of this I want to also fetch the news when booting. For this I
added the script I am using to fetch the articles to:
/etc/init.d/boot.local

But the script is not called when booting. Do I need to do something
else?

Also I also want to fetch the news after coming out of hibernation. Is
this possible?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Günther Schwarz

unread,
Oct 27, 2012, 6:25:39 PM10/27/12
to
Cecil Westerhof wrote:

> I installed leafnode. With cron I fetch every hour the new articles.
> Because of this I want to also fetch the news when booting. For this I
> added the script I am using to fetch the articles to:
> /etc/init.d/boot.local
>
> But the script is not called when booting.

Boot.local is processed prior to the network setup just after file
systems are mounted. That is too early for leafnode.

> Do I need to do something else?

Rather than using the preconfigured boot.local you might want to set up a
separate script for init and make sure that the SUSE specific headers
specify execution after the network is available.

Günther
Message has been deleted

bad sector

unread,
Oct 27, 2012, 7:57:23 PM10/27/12
to
On 10/27/2012 05:41 PM, Cecil Westerhof wrote:
> I installed leafnode. With cron I fetch every hour the new articles.
> Because of this I want to also fetch the news when booting. For this I
> added the script I am using to fetch the articles to:
> /etc/init.d/boot.local
>
> But the script is not called when booting. Do I need to do something
> else?
>
> Also I also want to fetch the news after coming out of hibernation. Is
> this possible?
>

~/.profile is run afetr login, it may still be too early but it's
certainly after boot.local


Cecil Westerhof

unread,
Oct 27, 2012, 10:08:48 PM10/27/12
to
Op zondag 28 okt 2012 00:33 CEST schreef hou...@houghi.org.invalid:

> Cecil Westerhof wrote:
>> I installed leafnode. With cron I fetch every hour the new articles.
>> Because of this I want to also fetch the news when booting. For this I
>> added the script I am using to fetch the articles to:
>> /etc/init.d/boot.local
>>
>> But the script is not called when booting. Do I need to do something
>> else?
>
> Turn on the logging and see what happens. Perhaps the network is not yet
> up and running properly.

That was part of the problem, but not at that moment. I used:
${HOME}/bin/leafnodeFetch.sh

But when boot.local is run HOME is not defined. Is this correct or a
bug? It took some time to find it. It is logged on the screen, but it
scrolls so fast, that you do not see it. And nothing ends up im
/var/log/messages. :-{


So I changed it to:
/root/bin/leafnodeFetch.sh

But then the network was not up. So I changed it to:
echo /root/bin/leafnodeFetch.sh | at now +1 minutes

And then the gremlins hit me. The command ended in the at queue, but was
not executed. Kept trying, but to no avail. It turned out that I hit
on another bug. Summer time ended here and when that happens a job
that is queued for 02:03 is not executed at the first time it becomes
02:03, but the second time. I think this is a bug.


>> Also I also want to fetch the news after coming out of hibernation. Is
>> this possible?
>
> Yes. /etc/pm/sleep.d/ is where you can add something like
>
> penne# cat /etc/pm/sleep.d/99run-leafnode
> #!/bin/bash
> case "$1" in
> hibernate|suspend)
> # Nothing
> ;;
> thaw|resume)
> /your/program -here
> ;;
> *)
> ;;
> esac
> exit 0

Works. Thanks. Here also HOME is not defined.

Cecil Westerhof

unread,
Oct 27, 2012, 10:15:23 PM10/27/12
to
Op zondag 28 okt 2012 00:25 CEST schreef Günther Schwarz:

>> I installed leafnode. With cron I fetch every hour the new articles.
>> Because of this I want to also fetch the news when booting. For this I
>> added the script I am using to fetch the articles to:
>> /etc/init.d/boot.local
>>
>> But the script is not called when booting.
>
> Boot.local is processed prior to the network setup just after file
> systems are mounted. That is too early for leafnode.

That was at that moment not the problem. I used:
${HOME}/bin/leafnodeFetch.sh

But when boot.local is run HOME is not defined.

So I changed it to:
/root/bin/leafnodeFetch.sh

But then the network was not up. So I changed it to:
echo /root/bin/leafnodeFetch.sh | at now +1 minutes


>
>> Do I need to do something else?
>
> Rather than using the preconfigured boot.local you might want to set up a
> separate script for init and make sure that the SUSE specific headers
> specify execution after the network is available.

I have a working solution, but in principal is this better of-course.
How should I implement this?
Message has been deleted

Günther Schwarz

unread,
Oct 28, 2012, 5:07:33 AM10/28/12
to
Cecil Westerhof wrote:

> Op zondag 28 okt 2012 00:25 CEST schreef Günther Schwarz:

>>> Do I need to do something else?
>>
>> Rather than using the preconfigured boot.local you might want to set up
>> a separate script for init and make sure that the SUSE specific headers
>> specify execution after the network is available.
>
> I have a working solution, but in principal is this better of-course.
> How should I implement this?

RTFM ;-)
Basically you will start from /etc/init.d/skeleton and change that to
your needs. The first part of the example scripts contains the
information about dependencies (start after network etc) which is
specific to SUSE Linux.
After that is done use chkconfig to add the new service to init.

Günther
Message has been deleted

Cecil Westerhof

unread,
Oct 28, 2012, 8:07:29 AM10/28/12
to
Op zondag 28 okt 2012 10:07 CET schreef Günther Schwarz:
I am new to this stuff. Thanks for the pointer: now I have something
to keep me of the street. ;-P

Cecil Westerhof

unread,
Oct 28, 2012, 8:05:21 AM10/28/12
to
Op zondag 28 okt 2012 09:49 CET schreef hou...@houghi.org.invalid:

>>> Turn on the logging and see what happens. Perhaps the network is not yet
>>> up and running properly.

By the way what did you mean by "turn on the logging"? I did not need
it this time, but maybe next time I will.


>> That was part of the problem, but not at that moment. I used:
>> ${HOME}/bin/leafnodeFetch.sh
>
> leafnode should not be run as a user, so $HOME is not the correct place.
>
> I always imagine that I have a life and with that at least a family and
> that they are all using the same PC. If a program is not strictly for
> me, I will place it in /usr/local/bin and if it is something that needs
> to be run as root in /usr/local/sbin

That is a good tip. I will change it and for some other scripts also.


>> But when boot.local is run HOME is not defined. Is this correct or a
>> bug? It took some time to find it. It is logged on the screen, but it
>> scrolls so fast, that you do not see it. And nothing ends up im
>> /var/log/messages. :-{
>
> It might depend on how your $HOME is cofigured. Could well be that your
> $HOME is on a network. I put only things in $HOME that I need when I am
> logged in. Programs and scripts that I run with cronjob have no place in
> $HOME. /usr/local/bin is the right place for them.

With cronjob ${HOME} is defined, so that is why it caught me by
surprise. Learned something. ;-)


>> And then the gremlins hit me. The command ended in the at queue, but was
>> not executed. Kept trying, but to no avail. It turned out that I hit
>> on another bug.
>
> Seems to me that that is a feature. at might not yet be running at that
> moment.

That was not the problem, because after it was 3 again, my problem was
resolved. So it is a bug/feature, not that at was not running.


>> Summer time ended here and when that happens a job
>> that is queued for 02:03 is not executed at the first time it becomes
>> 02:03, but the second time. I think this is a bug.
>
> I do not think so. atd starts a bit later. After suspend-> resume, it is
> started as planned in /etc/pm/sleep.d/

It went equally wrong with boot and resume. And both are no problem
anymore.


> You also have a program leafnodeFetch.sh. Is there a reason you do not
> use /usr/sbin/fetchnews directly?

Yes, to make sure fetchnews is not called to often:
#!/usr/bin/env bash

set -o errexit
set -o nounset

source /SharedFunctions/functions

declare -r LOG_DIR=/root/Logging
declare -r SCRIPT_NAME=$(basename ${0} .sh)

declare -r LOG_FILE=${LOG_DIR}/${SCRIPT_NAME}_$(date '+%F').log

# End template

# Script variables
declare -r LAST_FETCH=${LOG_DIR}/${SCRIPT_NAME}_LastFetch
declare -r SECS_BETWEEN_FETCHES=900
declare -r SECS_SINCE_LAST_FETCH=$(getFileChangedSecondsAgo "${LAST_FETCH}")

# Script functions
function fetchIsToSoon {
declare -r MESSAGE="Last fetch ${SECS_SINCE_LAST_FETCH} seconds ago, need at least ${SECS_BETWEEN_FETCHES}"

echo ${MESSAGE} >>${LOG_FILE}
if isInteractive ; then
echo ${MESSAGE}
fi
}


# Main script
(echo; echo) >>${LOG_FILE}
if [[ ${SECS_SINCE_LAST_FETCH} -lt ${SECS_BETWEEN_FETCHES} ]] ; then
fetchIsToSoon
exit
fi

(
showMessageNew y Start
/usr/local/sbin/fetchnews -vv
showMessageNew y End
) &>>${LOG_FILE}
touch ${LAST_FETCH}

Cecil Westerhof

unread,
Oct 28, 2012, 8:26:51 AM10/28/12
to
Op zondag 28 okt 2012 10:31 CET schreef hou...@houghi.org.invalid:

> Also note that xinitd must be up and running.

Is already up and running for leafnode. :-D


> What I would do is instead of doing all sorts of stuff, have a buildin
> check to see if the network is up and running or not. Or even if the
> remote server is reachable.
> If not, it will wait X time for Y tries.

A good idea. But I think I need both? Because the network is started
after boot.local and the network would not be up before the script has
ended? So this would just increase my boot time?

I also should call it before a shutdown or sleep, otherwise posts that
queued will not be send before booting/resuming. (Better to use a
leafnodePut, because fetching is not necessary. But that is a later
refinement.) Will the network still be up in halt.local?

Cecil Westerhof

unread,
Oct 28, 2012, 9:11:46 AM10/28/12
to
Op zondag 28 okt 2012 13:26 CET schreef Cecil Westerhof:

> I also should call it before a shutdown or sleep, otherwise posts that
> queued will not be send before booting/resuming. (Better to use a
> leafnodePut, because fetching is not necessary. But that is a later
> refinement.) Will the network still be up in halt.local?

That is not going to work. Both in halt.local and when going to
hibernate, the network is already down. :-(

Cecil Westerhof

unread,
Oct 28, 2012, 9:47:11 AM10/28/12
to
Op zaterdag 27 okt 2012 23:41 CEST schreef Cecil Westerhof:

> I installed leafnode. With cron I fetch every hour the new articles.
> Because of this I want to also fetch the news when booting. For this I
> added the script I am using to fetch the articles to:
> /etc/init.d/boot.local
>
> But the script is not called when booting. Do I need to do something
> else?
>
> Also I also want to fetch the news after coming out of hibernation. Is
> this possible?

I can make everything a lot easier for myself. As I understood it
leafnode had to be accessed locally and you need to do stuff to make
it available on your local network. That seems not to be the case. I
just tried to connect from my server to leafnode on my PC and it
worked like a charm. So I expect that the other-way around should work
also. :-)

The server is always online, so I do not have to care about boot,
hibernate, waking up and shutdown. I only need a way to instruct
leafnode on the server to fetch again from the PC. But that should not
be a big problem I suppose. So lets install it again.

But if there is a way to automatically send the queued messages on
shutdown and hibernate, I still would like to know how. Then I could
make it work for people without a server also.
Message has been deleted
Message has been deleted
Message has been deleted

Cecil Westerhof

unread,
Oct 28, 2012, 11:41:41 AM10/28/12
to
Op zondag 28 okt 2012 15:39 CET schreef hou...@houghi.org.invalid:

> Cecil Westerhof wrote:
>> A good idea. But I think I need both? Because the network is started
>> after boot.local and the network would not be up before the script has
>> ended? So this would just increase my boot time?
>
> Start it as `script &` and it should work.

That should work yes. With the hibernate and shutdown it would slow
things down, so there I should not use it.

Cecil Westerhof

unread,
Oct 28, 2012, 11:45:38 AM10/28/12
to
Op zondag 28 okt 2012 15:37 CET schreef hou...@houghi.org.invalid:

> Cecil Westerhof wrote:
>>> You also have a program leafnodeFetch.sh. Is there a reason you do not
>>> use /usr/sbin/fetchnews directly?
>>
>> Yes, to make sure fetchnews is not called to often:
>
> That is what cron is for. I run it every 15 minutes. My crontab
> entry

Yes and no. ;-) With cron I fetch it every hour. Normally that would
be more as alright I think. But when I posted something, or am
awaiting something, then it would be nice not have to wait for an
hour. :-D
Message has been deleted

Rajko M.

unread,
Oct 28, 2012, 11:14:59 PM10/28/12
to
On 10/27/2012 04:41 PM, Cecil Westerhof wrote:
> I installed leafnode. With cron I fetch every hour the new articles.
> Because of this I want to also fetch the news when booting. For this I
> added the script I am using to fetch the articles to:
> /etc/init.d/boot.local
>
> But the script is not called when booting. Do I need to do something
> else?

Most likely read-a-lot about systemd and how to create service unit.

http://forums.opensuse.org/blogs/jdmcdaniel3/systemd-using-after-local-script-opensuse-12-1-71/

(above is one line, of course :) )

> Also I also want to fetch the news after coming out of hibernation. Is
> this possible?

Most likely yes, the change is to read-a-lot about hibernation.

--
Regards, Rajko.
0 new messages