View previous topic :: View next topic |
Author |
Message |
silian87 Advocate
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
Posted: Sun Nov 21, 2004 3:06 pm Post subject: [UTILITY] Script dhcp per gentoo |
|
|
Penso che se ne sia gia' parlato, volevo postarvi questo scriptino che ho fatto per farmi andare il dhcp alla partenza solo se il cavo di rete e' collegato. In caso che sia scollegato vi rimane l'ip statico dato da net.eth0. Quindi dovrete prima cambiare in /etc/conf.d/net, da dinamico a statico.
Code: | #!/sbin/runscript
depend()
{
need net.eth0
}
start()
{
/bin/sleep 2
link_down=`/sbin/mii-tool | /bin/grep "no link"`
if [ "$link_down" = "" ]
then
ebegin "Starting net.dynamic"
dhcpcd eth0
#/bin/echo "nameserver 127.0.0.1" > /etc/resolv.conf
eend ${?}
else
eerror "No net cable found!"
return 1
fi
}
stop()
{
ebegin "Stoppig net.dynamic"
/etc/init.d/net.eth0 stop
eend ${?}
}
|
Va messo in /etc/init.d/net.dynamic
Potete aggiungerlo al runlevel di default con rc-update add net.dynamic default.
Se il vostro pc ha il server dns locale, dedommentate questa riga:
Code: | #/bin/echo "nameserver 127.0.0.1" > /etc/resolv.conf |
Natuarlmante e' uno script non fatto benissimo, del tipo che non ho usato un'altro script di configuarazione, ma solo questo, pero' sembra funzionare (se avete proplemi di lentezza, aumentate i secondi di sleep).
Spero possa servire a qualcuno _________________ Musica che ascolto: http://www.last.fm/user/silian87/
Silian87 FAQs: http://marentax.homelinux.org/~silian87/silian87-faq.txt
GTalk: silian87@gmail.com |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30925 Location: here
|
Posted: Sun Nov 21, 2004 5:09 pm Post subject: |
|
|
Ed usare ifplugd che fa tutto questo? _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
X-Drum Advocate
Joined: 24 Aug 2003 Posts: 2517 Location: ('Modica','Trieste','Ferrara') Italy
|
Posted: Sun Nov 21, 2004 5:12 pm Post subject: |
|
|
fedeliallalinea wrote: | Ed usare ifplugd che fa tutto questo? |
....non è da "ackari" _________________ "...There are two sort of lies, lies and benchmarks..." |
|
Back to top |
|
|
silian87 Advocate
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30925 Location: here
|
Posted: Sun Nov 21, 2004 5:15 pm Post subject: |
|
|
silian87 wrote: | mmmm e'.... mi sa che lo provero'... |
Bello anche il tuo ma ormai uso da tempo ifplugd e va benissimo _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
silian87 Advocate
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
|
Back to top |
|
|
silian87 Advocate
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
|
Back to top |
|
|
Raffo Veteran
Joined: 23 Apr 2004 Posts: 1019 Location: Berlin
|
Posted: Sun Nov 21, 2004 5:39 pm Post subject: |
|
|
cos'è questo ifplugd?? mi documento va.... |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30925 Location: here
|
Posted: Sun Nov 21, 2004 5:42 pm Post subject: |
|
|
Raffo wrote: | cos'è questo ifplugd?? mi documento va.... |
Niente semplicemente ti alza la rete sono se il cavo e' attacato. Se e' staccato e poi lo atacchi fa partire lui automaticamente _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
Raffo Veteran
Joined: 23 Apr 2004 Posts: 1019 Location: Berlin
|
Posted: Sun Nov 21, 2004 5:44 pm Post subject: |
|
|
quindi vado di "emerge ifplugd" |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30925 Location: here
|
Posted: Sun Nov 21, 2004 5:45 pm Post subject: |
|
|
Raffo wrote: | quindi vado di "emerge ifplugd" |
Si poi lo configuri togli il runlevel net.eth0 e metti ifplugd _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
Raffo Veteran
Joined: 23 Apr 2004 Posts: 1019 Location: Berlin
|
Posted: Sun Nov 21, 2004 5:51 pm Post subject: |
|
|
quindi edito ifplugd e faccio Code: |
rc-update del net default
rc-update add ifplugd default |
le righe Code: | iface_eth0="dhcp"
dhcpcd_eth0="-h localhost -t 10"
|
che sono in net le devo copiare in ifplugd?? |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30925 Location: here
|
Posted: Sun Nov 21, 2004 6:21 pm Post subject: |
|
|
No rc-update del net.eth0 default . Per configurare ifplugd cerca un post di MyZelf _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
Raffo Veteran
Joined: 23 Apr 2004 Posts: 1019 Location: Berlin
|
Posted: Sun Nov 21, 2004 6:50 pm Post subject: |
|
|
ho seguito il tip trovato, ma nn ne vuole sapere di andare.... |
|
Back to top |
|
|
|