|
Revision 273, 1.1 KB
(checked in by root, 10 months ago)
|
|
Various fixes I should have synced earlier and one new feature (!).
Now it will attept to save and then use the last address it got from the DHCP server through reboots.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # $Id$ |
|---|
| 4 | |
|---|
| 5 | # |
|---|
| 6 | # Grabbing the config. |
|---|
| 7 | # |
|---|
| 8 | . /etc/config |
|---|
| 9 | |
|---|
| 10 | # |
|---|
| 11 | # Grabbing the function library. |
|---|
| 12 | # |
|---|
| 13 | . /etc/functions.inc |
|---|
| 14 | |
|---|
| 15 | HARGS= |
|---|
| 16 | [ "$USER_IDENT" != "" ] && HARGS="-H $USER_IDENT" |
|---|
| 17 | |
|---|
| 18 | if $(bool_value "$DHCP_USE_LAST_ADDR" && [ -f /mnt/tmp/dhcp.add ]) |
|---|
| 19 | then |
|---|
| 20 | # We're going to need an address |
|---|
| 21 | # mount -t $SOURCE_FS $SOURCE_DEV /mnt/tmp |
|---|
| 22 | LAST_DHCP_ADDR=$(cat /mnt/tmp/dhcp.add | tr -d '\n' | tr -d '\r') |
|---|
| 23 | # if [ -n "$LAST_DHCP_ADDR" ] |
|---|
| 24 | if [ "$LAST_DHCP_ADDR" != "" ] |
|---|
| 25 | then |
|---|
| 26 | echo "Gonna ask for $LAST_DHCP_ADDR" |
|---|
| 27 | if /sbin/udhcpc -t 3 -r $LAST_DHCP_ADDR -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV |
|---|
| 28 | then |
|---|
| 29 | . /etc/outside.info |
|---|
| 30 | echo $OUTSIDE_IP > /mnt/tmp/dhcp.add 2> /dev/null |
|---|
| 31 | exit 0 |
|---|
| 32 | fi |
|---|
| 33 | fi |
|---|
| 34 | fi |
|---|
| 35 | |
|---|
| 36 | # |
|---|
| 37 | # OK, either we did not have an existing address or we did not get it. |
|---|
| 38 | # |
|---|
| 39 | if /sbin/udhcpc -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV |
|---|
| 40 | then |
|---|
| 41 | if $(bool_value "$DHCP_USE_LAST_ADDR" && touch /mnt/tmp/dhcp.add 2> /dev/null) |
|---|
| 42 | then |
|---|
| 43 | . /etc/outside.info |
|---|
| 44 | echo $OUTSIDE_IP > /mnt/tmp/dhcp.add 2> /dev/null |
|---|
| 45 | fi |
|---|
| 46 | exit 0 |
|---|
| 47 | else |
|---|
| 48 | exit 1 |
|---|
| 49 | fi |
|---|