Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
run script before swapon how?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Thu Feb 16, 2006 6:20 am    Post subject: run script before swapon how? Reply with quote

Hi,

I need to run

/etc/init.d/dumputils start

before my swap is turned on. I entered that exactly right before swapon in /sbin/rc. For some reason it appears that it's not running at all. This is a script that configures and starts the lkcd utility for kernel debugging. I just want to know how I can get it running before swapon? Can I just add it to a runlevel? Which one?

Alternatively I could disable swapon and do all this manually. But I'm not convinced it's being run from there.
Back to top
View user's profile Send private message
zsoltika
l33t
l33t


Joined: 13 Nov 2003
Posts: 634
Location: Budapest, Hungary

PostPosted: Thu Feb 16, 2006 8:34 am    Post subject: Reply with quote

As far as I can see while booting the '/etc/init.d/localmount' script takes care of swapon. So you can add your initscript to the previous one's 'depend' list. Or just simply edit the 'localmount' script and add your prefered lines before the
Code:
/sbin/swapon -a
line.
HTH
_________________
Do not believe that Guru thing under my nickname.
Back to top
View user's profile Send private message
Leo Lausren
Apprentice
Apprentice


Joined: 24 Feb 2004
Posts: 198
Location: Denmark

PostPosted: Thu Feb 16, 2006 10:36 am    Post subject: Re: run script before swapon how? Reply with quote

goldfita wrote:
I need to run
/etc/init.d/dumputils start
before my swap is turned on.

How about putting:
Code:
depend() {
    before localmount
}
in your dumputils script :?:
_________________
Blog: common sense – nonsense
Back to top
View user's profile Send private message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Thu Feb 16, 2006 5:47 pm    Post subject: Reply with quote

Quote:

How about putting:
Code:
depend() {
before localmount
}
in your dumputils script


I saw that /sbin/rc was in inittab under start scripts or something like that. So I thought that was my best bet. Do I need to then add dumputils to a runlevel? I'm wondering how gentoo knows to run that script before local mount. Does it read through all the depend functions before running any scripts? Or is this checked when you rc-update?
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Thu Feb 16, 2006 6:08 pm    Post subject: Reply with quote

Dependencies are read and cached at rc-update and also possibly at other times. You would need to add your dumputils to the same runlevel as localmount.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Thu Feb 16, 2006 8:30 pm    Post subject: Reply with quote

I added dumputils to boot with rc-update after adding the dependency mentioned before. I see the usage message displayed 3 times at startup. But it was never actually run. The usage script looks like

dumputils {start|stop|reload|force-reload|restart}

Was there something else?
Back to top
View user's profile Send private message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Fri Feb 17, 2006 3:31 am    Post subject: Reply with quote

Ok, I got it. I had to rewrite it using functions and remove the case statement and exit commands.

I can see it running at startup now. But I'm not convinced it's happening at the correct time. It appears to be happening right before the ethernet interface is brought up, which is in the default run level. So unless localmount has no output, something must be wrong. Is there anyway I can verify the script load order? 'rc-update show' shows dumputils in boot.

thanks
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Fri Feb 17, 2006 7:05 am    Post subject: Reply with quote

localmount will display "Mounting local filesystems".

I'm not sure of a tool to verify the load order, but you can look at /var/lib/init.d/deptree.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
Leo Lausren
Apprentice
Apprentice


Joined: 24 Feb 2004
Posts: 198
Location: Denmark

PostPosted: Fri Feb 17, 2006 1:01 pm    Post subject: Reply with quote

goldfita wrote:
Ok, I got it. I had to rewrite it using functions and remove the case statement and exit commands.
But I'm not convinced it's happening at the correct time.

It seems that swapon is called at sometime before localmount, possibly from /sbin/rc (as you noted),
together vith udev pts and such.

You will probably need to take the functional part (ie. the start function's content) and add it to /sbin/rc
or maybe call the script with the argument "start" from there.
_________________
Blog: common sense – nonsense
Back to top
View user's profile Send private message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Fri Feb 17, 2006 6:32 pm    Post subject: Reply with quote

Quote:

It seems that swapon is called at sometime before localmount, possibly from /sbin/rc (as you noted),
together vith udev pts and such.


The swapon command is in rc (under runlevel sysinit I think), but as far as I can tell, that code is never executed. No matter what I put there, it isn't getting executed. I tried the scripy and copy/pasting the commands right in there. It must be getting turned on somewhere else.

Thanks for your help. I might give up on this. It's no longer critical to get this script running.
Back to top
View user's profile Send private message
goldfita
n00b
n00b


Joined: 27 Nov 2005
Posts: 40

PostPosted: Fri Feb 17, 2006 8:21 pm    Post subject: Reply with quote

I was able to verify the order using log files. Despite depend, localmount is running first. And that's where swapon is being run.
Back to top
View user's profile Send private message
synss
Apprentice
Apprentice


Joined: 08 Mar 2006
Posts: 282
Location: Dijon > Berlin > Tokyo > Nürnberg > München

PostPosted: Thu May 04, 2006 6:13 pm    Post subject: Reply with quote

Hello,

I pop in to say that even /etc/init.d/test
Code:
#!/sbin/runscript

depend() {
   before bootmisc
}

start() {
   einfo "Hum... I am late"
   ewarn "The before thing does not work that well in the boot runlevel!"
}


rc-update add test boot And that is also true with before localmount and others, even hdparm that is not home-made (synss-made) does not start before bootmisc as depend() suggests... That's a bug right?

As such, test is the last script executed at the boot runlevel (on x86, with everything up-to-date, but that's a while I noticed that)

[EDIT] The issue is known and addressed in sys-apps/baselayout-1.12* now in the ~x86 branch.
_________________
Compress portage tree
Elog viewer
Autodetect swap
Back to top
View user's profile Send private message
damogran
n00b
n00b


Joined: 12 Jan 2005
Posts: 43

PostPosted: Mon Jun 19, 2006 11:50 am    Post subject: Reply with quote

Hi,

i got that kind of problem too.
I need to load an init script before the localmount init script starts. I've read the gentoo init script guide an played with the depend / before / need stuff in the init scripts. but without success.

The depend part of my initscript (called dasd_init):
Code:
depend() {
  before localmount
  after modules
}


... and from localmount
Code:
depend() {
       after checkfs dasd_init
}


Why is localmount still starting before dasd_init?

<- :?:
Back to top
View user's profile Send private message
synss
Apprentice
Apprentice


Joined: 08 Mar 2006
Posts: 282
Location: Dijon > Berlin > Tokyo > Nürnberg > München

PostPosted: Mon Jun 19, 2006 5:08 pm    Post subject: Reply with quote

The answer can be found here:
https://forums.gentoo.org/viewtopic-t-184934-highlight-critical+initscript.html
https://forums.gentoo.org/viewtopic-t-223311-highlight-critical+initscript.html

I'll report the duplicates.
_________________
Compress portage tree
Elog viewer
Autodetect swap
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum