Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Run a script when no DHCP server available
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mannyl
n00b
n00b


Joined: 11 Dec 2002
Posts: 7

PostPosted: Mon Mar 10, 2003 8:29 am    Post subject: Run a script when no DHCP server available Reply with quote

I will be taking a gentoo system to mutiple locations some have a DHCP server some do not. When I have the system at a location with no DHCP server I want a script to run that sets some network settings, How can I do this?
Back to top
View user's profile Send private message
TheQuickBrownFox
n00b
n00b


Joined: 08 Oct 2002
Posts: 37

PostPosted: Mon Mar 10, 2003 9:16 am    Post subject: the hax0r way to do this... Reply with quote

The _wrong_ way to do this is to edit /etc/init.d/net.eth0 and put an extra line in after line 39 (in the standard file), the line that says: 'eend ${retval} "Failed to bring ${IFACE} up" '.

Just run your script at that point.

It's ugly, but should work. I'll be watching out for the better way...
_________________
-- jumps over the lazy dog
Back to top
View user's profile Send private message
mannyl
n00b
n00b


Joined: 11 Dec 2002
Posts: 7

PostPosted: Mon Mar 10, 2003 1:23 pm    Post subject: Reply with quote

So I shouldn't add to it /usr/sbin/iwconfig "eth0 mode ad-hoc"
and the rest of the script lines then because that is the dirty way to do it and not propper way. Right?
Back to top
View user's profile Send private message
Sven Vermeulen
Retired Dev
Retired Dev


Joined: 29 Aug 2002
Posts: 1345
Location: Mechelen, Belgium

PostPosted: Mon Mar 10, 2003 5:09 pm    Post subject: Reply with quote

I haven't checked it yet, but you can do this without editing the /etc/init.d/net.ethX script, but by changing the dhcpcd_ethX variable in /etc/conf.d:

Code:

dhcpcd_eth1="-t 10 || ifconfig eth1 192.168.0.10 up && route add default gw 192.168.0.254"


Make eth1 use dhcpcd. When run, dhcpcd will search for a DHCP-server and request the necessary information. If it fails (after 10 seconds) the "||" will make sure the ifconfig-thingie will get executed. If that works, then the "&&" will make sure that the route-thingie is executed.

I think the idea is good, dunno if in reality this would work.
Back to top
View user's profile Send private message
Sven Vermeulen
Retired Dev
Retired Dev


Joined: 29 Aug 2002
Posts: 1345
Location: Mechelen, Belgium

PostPosted: Mon Mar 10, 2003 5:28 pm    Post subject: Reply with quote

I just received word that this won't work. However, there has already been a bugreport (with solution) for this:
[url]
https://bugs.gentoo.org/show_bug.cgi?id=17162
[/url]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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