View previous topic :: View next topic |
Author |
Message |
mannyl n00b
Joined: 11 Dec 2002 Posts: 7
|
Posted: Mon Mar 10, 2003 8:29 am Post subject: Run a script when no DHCP server available |
|
|
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 |
|
|
TheQuickBrownFox n00b
Joined: 08 Oct 2002 Posts: 37
|
Posted: Mon Mar 10, 2003 9:16 am Post subject: the hax0r way to do this... |
|
|
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 |
|
|
mannyl n00b
Joined: 11 Dec 2002 Posts: 7
|
Posted: Mon Mar 10, 2003 1:23 pm Post subject: |
|
|
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 |
|
|
Sven Vermeulen Retired Dev
Joined: 29 Aug 2002 Posts: 1345 Location: Mechelen, Belgium
|
Posted: Mon Mar 10, 2003 5:09 pm Post subject: |
|
|
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 |
|
|
Sven Vermeulen Retired Dev
Joined: 29 Aug 2002 Posts: 1345 Location: Mechelen, Belgium
|
|
Back to top |
|
|
|