diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-06-21 01:23:24 +0000 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-06-21 01:23:24 +0000 |
commit | e30e8fe22035ebea101a88ead515a962936e6d31 (patch) | |
tree | 731dd4f8e912bfc73cf6307092dc1dc94540b97a /scripts | |
parent | bfc8a01de337eb28ea5a6597336635c107fafb63 (diff) | |
download | vyatta-cfg-e30e8fe22035ebea101a88ead515a962936e6d31.tar.gz vyatta-cfg-e30e8fe22035ebea101a88ead515a962936e6d31.zip |
better handling of dhcp release/renew commands
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta-interfaces.pl | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 6fdba14..f1c6bbe 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -252,6 +252,7 @@ sub update_eth_addrs { if ($addr eq "dhcp") { run_dhclient($intf); + system ("touch /var/lib/dhcp3/$intf\;"); return; } my $version = is_ip_v4_or_v6($addr); @@ -297,7 +298,7 @@ sub delete_eth_addrs { if ($addr eq "dhcp") { stop_dhclient($intf); - system("rm -f /var/lib/dhcp3/dhclient_$intf\_lease"); + system("rm -f /var/lib/dhcp3/dhclient_$intf\_lease; rm -f /var/lib/dhcp3/$intf\; rm -f /var/lib/dhcp3/$intf\_release;"); exit 0; } my $version = is_ip_v4_or_v6($addr); @@ -441,14 +442,22 @@ sub op_dhcp_command { print "$intf is not using DHCP to get an IP address\n"; exit 1; } - + + my $release_file = $dhclient_dir . $intf . '_release'; if ($op_command eq "dhcp-release") { - print "Releasing DHCP lease on $intf ...\n"; - stop_dhclient($intf); - exit 0; + if (-e $release_file) { + print "IP address for $intf has already been released.\n"; + exit 1; + } else { + print "Releasing DHCP lease on $intf ...\n"; + stop_dhclient($intf); + system ("touch $release_file\;"); + exit 0; + } } elsif ($op_command eq "dhcp-renew") { print "Renewing DHCP lease on $intf ...\n"; run_dhclient($intf); + system ("rm -f $release_file\;"); exit 0; } |