diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-11-14 16:11:32 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-11-14 16:11:32 -0800 |
commit | 160d05043a4b36d519b1e0aeff540c428dac38dd (patch) | |
tree | 46d6d1b5b0032d9b0595f4622bc14fc821663dcb /scripts/vyatta-interfaces.pl | |
parent | a79dc66234f32de6fdf1d16b69129f5722f824e9 (diff) | |
download | vyatta-cfg-160d05043a4b36d519b1e0aeff540c428dac38dd.tar.gz vyatta-cfg-160d05043a4b36d519b1e0aeff540c428dac38dd.zip |
Implement touch in perl
Use perl to do the touch command.
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rw-r--r-- | scripts/vyatta-interfaces.pl | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index d382922..b60f0ba 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -37,6 +37,7 @@ use VyattaMisc; use Getopt::Long; use POSIX; use NetAddr::IP; +use Fcntl; use strict; use warnings; @@ -44,7 +45,6 @@ use warnings; my $dhcp_daemon = '/sbin/dhclient'; my $dhclient_dir = '/var/lib/dhcp3/'; - my ($eth_update, $eth_delete, $addr, $dev, $mac, $mac_update, $op_dhclient); GetOptions("eth-addr-update=s" => \$eth_update, @@ -96,6 +96,14 @@ sub is_ip_duplicate { } } +sub touch { + my $file = shift; + my $t = time; + + sysopen (my $f, $file, O_RDWR|O_CREAT) or die "Can't touch $file"; + close $f; + utime $t, $t, $file; +} sub dhcp_write_file { my ($file, $data) = @_; @@ -263,8 +271,8 @@ sub update_eth_addrs { my ($addr, $intf) = @_; if ($addr eq "dhcp") { + touch("/var/lib/dhcp3/$intf"); run_dhclient($intf); - system ("touch /var/lib/dhcp3/$intf\;"); return; } my $version = is_ip_v4_or_v6($addr); @@ -467,7 +475,7 @@ sub op_dhcp_command { if(! -d $tmp_dhclient_dir ){ system ("mkdir $tmp_dhclient_dir\;"); } - system ("touch $release_file\;"); + touch($release_file); exit 0; } } elsif ($op_command eq "dhcp-renew") { |