[Lugro-mesh] Uso del udhcp
Gustavo Lindberg
gus.lindberg en gmail.com
Mie Abr 9 21:56:33 ART 2008
Que tipo....
#!/bin/sh
[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
. /etc/functions.sh
include /lib/network
RESOLV_CONF="/tmp/resolv.conf.auto"
hotplug_event() {
scan_interfaces
for ifc in $interfaces; do
config_get ifname $ifc ifname
[ "$ifname" = "$interface" ] || continue
config_get proto $ifc proto
[ "$proto" = "dhcp" ] || continue
[ ifup = "$1" ] && {
uci_set_state network "$ifc" ipaddr "$ip"
uci_set_state network "$ifc" netmask
"${subnet:-255.255"
uci_set_state network "$ifc" dnsdomain "$domain"
uci_set_state network "$ifc" dns "$dns"
uci_set_state network "$ifc" gateway "$router"
}
env -i ACTION="$1" INTERFACE="$ifc" DEVICE="$ifname"
PROTO=dhcpe
done
}
case "$1" in
deconfig)
ifconfig $interface 0.0.0.0
hotplug_event ifdown
;;
renew|bound)
ifconfig $interface $ip \
netmask ${subnet:-255.255.255.0} \
broadcast ${broadcast:-+}
[ -n "$router" ] && {
for i in $router ; do
echo "adding router $i"
route add default gw $i dev $interface
valid="$valid|$i"
done
echo "deleting old routes"
$(route -n | awk '/^0.0.0.0\W{9}('$valid')\W/ {next}
/^)
}
[ -n "$dns" ] && {
echo -n > "${RESOLV_CONF}.tmp"
${domain:+echo search $domain} >>
"${RESOLV_CONF}.tmp"
for i in $dns ; do
echo "adding dns $i"
echo "nameserver $i" >> "${RESOLV_CONF}.tmp"
done
mv "${RESOLV_CONF}.tmp" "$RESOLV_CONF"
/sbin/reboot # Esto lo puse yo <<<<<<<<<<<
}
hotplug_event ifup
# user rules
[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
;;
esac
exit 0
El día 9/04/08, Sebastián D. Criado <sebastian.criado en gmail.com> escribió:
>
> Bueno, me lo podes pasar POR FAVOR :D
>
> El 9/04/08, Gustavo Lindberg <gus.lindberg en gmail.com> escribió:
>
> > Es muy simple, copia el que ya existe con otro nombre y al final del
> case
> > que nombre agregale una linea /sbin/reboot.
> > Despues lanza el udhcpc tal cual comentaba antes.
> > El script es complejo, usa el hotplug. Yo lo hice facil, le agregue una
> > linea al final del evento que nos interesa.... :P
> >
> >
> >
> > El día 9/04/08, Sebastián D. Criado <> escribió:
> > >
> > > El 9/04/08, Gustavo Lindberg <> escribió:
> > >
> > > > Peligroso ? Y en que caso alguien se arrepentiria ?? Esto vendria a
> > resolver
> > > > el hecho que si en un nodo cliente se enciende un dhcpd y eth0 toma
> ip,
> > se
> > > > agregaria un default router y el nodo quedaria en un estado extranio
> > hasta
> > > > que el cron lo reinicie. Pensemos que en una malla un nodo cliente
> puede
> > > > operar como gw de otro cliente vecino y si se alteran las tablas de
> > ruteo
> > > > que pasa con la malla toda ??
> > > >
> > >
> > >
> > > Mm, es verdad, el modo extraño es raro y peligroso.
> > > Pasame por favor el script que lo veo.
> > >
> > >
> > > Saludos.-
> > >
> > >
> > >
> > > --
> > > Sebastián D. Criado - scriado{en}ciudad.com.ar
> > > NO A LA MATRICULACIÓN OBLIGATORIA -
> > http://noalamatricula.wordpress.com/about/
> > > L.U.G.Ro - http://www.lugro.org.ar
> > > GNU/Linux Registered User # 146768
> > > -
> > -------------------------------------------------------------------
> > > "Si el Universo fuera un programa estaría hecho en C, y correría sobre
> > > un sistema UNIX"
> > >
> > Anónimo.
> > >
> > > _______________________________________________
> > > Lugro-mesh mailing list
> > > Lugro-mesh en lugro.org.ar
> > > http://www.lugro.org.ar/mailman/listinfo/lugro-mesh
> > >
> >
> >
> > _______________________________________________
> > Lugro-mesh mailing list
> > Lugro-mesh en lugro.org.ar
> > http://www.lugro.org.ar/mailman/listinfo/lugro-mesh
> >
> >
>
>
>
> --
>
> Sebastián D. Criado - scriado{en}ciudad.com.ar
> NO A LA MATRICULACIÓN OBLIGATORIA -
> http://noalamatricula.wordpress.com/about/
> L.U.G.Ro - http://www.lugro.org.ar
> GNU/Linux Registered User # 146768
> - -------------------------------------------------------------------
> "Si el Universo fuera un programa estaría hecho en C, y correría sobre
> un sistema UNIX"
> Anónimo.
>
> _______________________________________________
> Lugro-mesh mailing list
> Lugro-mesh en lugro.org.ar
> http://www.lugro.org.ar/mailman/listinfo/lugro-mesh
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://www.lugro.org.ar/pipermail/lugro-mesh/attachments/20080409/6ddd8820/attachment-0001.htm
Más información sobre la lista de distribución Lugro-mesh