summaryrefslogtreecommitdiff
path: root/scripts/system/vyatta_update_resolv.pl
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-06-21 11:09:51 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-06-21 11:09:51 -0700
commitd801c05f63b0b16f485b176db64e3147ad7d3086 (patch)
tree9829f0bf340a55986aa6d11f1b1d8d5334306abd /scripts/system/vyatta_update_resolv.pl
parent6d59b5077ef1834379a950437b01d15d687c7a53 (diff)
parent7369bf61abd3eed1fdd17a56908cf2c0ffc9843f (diff)
downloadvyatta-cfg-quagga-d801c05f63b0b16f485b176db64e3147ad7d3086.tar.gz
vyatta-cfg-quagga-d801c05f63b0b16f485b176db64e3147ad7d3086.zip
Merge branch 'larkspur' of http://git.vyatta.com/vyatta-cfg-system into larkspur
Diffstat (limited to 'scripts/system/vyatta_update_resolv.pl')
-rwxr-xr-xscripts/system/vyatta_update_resolv.pl32
1 files changed, 18 insertions, 14 deletions
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl
index 7f2b84b2..a4e2b9ba 100755
--- a/scripts/system/vyatta_update_resolv.pl
+++ b/scripts/system/vyatta_update_resolv.pl
@@ -134,10 +134,11 @@ if ($dhclient_script == 1) {
}
}
if ($ns_in_resolvconf == 0) {
- open (APPEND, ">>/etc/resolv.conf") or die "$! error trying to overwrite";
- print APPEND "nameserver\t$ns\t\t#nameserver written by $0\n";
- close (APPEND);
- $restart_ntp = 1;
+ open (my $rf, '>>', '/etc/resolv.conf')
+ or die "$! error trying to overwrite";
+ print $rf "nameserver\t$ns\t\t#nameserver written by $0\n";
+ close $rf;
+ $restart_ntp = 1;
}
}
}
@@ -190,37 +191,40 @@ if ($dhclient_script == 1) {
my @resolv;
if (-e '/etc/resolv.conf') {
- open (RESOLV, '</etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for input: $!\n");
- @resolv = <RESOLV>;
- close (RESOLV);
+ open (my $f, '<', '/etc/resolv.conf')
+ or die("$0: Error! Unable to open '/etc/resolv.conf' for input: $!\n");
+ @resolv = <$f>;
+ close ($f);
}
my $foundSearch = 0;
my $foundDomain = 0;
-open (RESOLV, '>/etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n");
+open (my $r, '>', '/etc/resolv.conf')
+ or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n");
+
foreach my $line (@resolv) {
if ($line =~ /^search\s/) {
$foundSearch = 1;
if (length($search) > 0) {
- print RESOLV $search;
+ print $r $search;
}
} elsif ($line =~ /^domain\s/) {
$foundDomain = 1;
if (length($domain) > 0) {
- print RESOLV $domain;
+ print $r $domain;
}
} else {
- print RESOLV $line;
+ print $r $line;
}
}
if ($foundSearch == 0 && length($search) > 0) {
- print RESOLV $search;
+ print $r $search;
}
if ($foundDomain == 0 && length($domain) > 0) {
- print RESOLV $domain;
+ print $r $domain;
}
-close (RESOLV);
+close ($r);