summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dhcpv6-client-show-leases.pl10
-rw-r--r--scripts/rename-image.pl21
-rwxr-xr-xscripts/vyatta-op-dns-forwarding.pl51
-rwxr-xr-xscripts/vyatta-reboot.pl2
4 files changed, 63 insertions, 21 deletions
diff --git a/scripts/dhcpv6-client-show-leases.pl b/scripts/dhcpv6-client-show-leases.pl
index 546668c..44be689 100644
--- a/scripts/dhcpv6-client-show-leases.pl
+++ b/scripts/dhcpv6-client-show-leases.pl
@@ -74,13 +74,11 @@ my %ghash = ();
foreach my $lease_filename (@lease_files) {
my @lines=();
- if (!open(LEASE_FILE, "</var/lib/dhcp3/$lease_filename")) {
- printf("Can't open lease file for reading: $lease_filename\n");
- exit 1;
- }
+ open(my $f, '<', "/var/lib/dhcp3/$lease_filename")
+ or die "Can't open lease file for reading: $lease_filename\n";
- @lines = <LEASE_FILE>;
- close(LEASE_FILE);
+ @lines = <$f>;
+ close $f;
chomp @lines;
my $level = 0;
diff --git a/scripts/rename-image.pl b/scripts/rename-image.pl
index 8632334..be30967 100644
--- a/scripts/rename-image.pl
+++ b/scripts/rename-image.pl
@@ -24,6 +24,8 @@ use strict;
use warnings;
use Getopt::Long;
use File::Temp qw/ tempfile tempdir /;
+use File::Copy;
+use Sys::Syslog qw/:standard :macros/;
my $UNION_BOOT = '/live/image/boot';
my $XEN_DEFAULT_IMAGE = "$UNION_BOOT/%%default_image";
@@ -99,16 +101,14 @@ my $tmpfh;
my $tmpfilename;
($tmpfh, $tmpfilename) = tempfile();
-if (!open (GRUBFH, "<${image_path}/grub/grub.cfg")) {
- printf("Can't open grub file.\n");
- exit 1;
-}
+open (my $grubfh, '<', "${image_path}/grub/grub.cfg")
+ or die "Can't open grub file.\n";
# This is sensitive to the format of menu entries and boot paths
# in the grub config file.
#
my $line;
-while ($line = <GRUBFH>) {
+while ($line = <$grubfh>) {
$line =~ s/\/boot\/$old_name/\/boot\/$new_name/g;
$line =~ s/Vyatta $old_name/Vyatta $new_name/;
$line =~ s/Vyatta image $old_name/Vyatta image $new_name/;
@@ -117,13 +117,14 @@ while ($line = <GRUBFH>) {
}
close($tmpfh);
-close(GRUBFH);
+close($grubfh);
-system("mv $image_path/$old_name $image_path/$new_name");
-system("cp $tmpfilename $image_path/grub/grub.cfg");
+mv("$image_path/$old_name", "$image_path/$new_name")
+ or die "rename $old_name to $new_name failed: $!\n";
+cp($tmpfilename, "$image_path/grub/grub.cfg")
+ or die "copy $tmpfilename to grub.cfg failed: $!\n";
-system("logger -p local3.warning -t 'SystemImage' 'System image $old_name has been renamed $new_name'");
+syslog("warning", "System image $old_name has been renamed $new_name");
printf("Done.\n");
-
diff --git a/scripts/vyatta-op-dns-forwarding.pl b/scripts/vyatta-op-dns-forwarding.pl
index 99b5eac..a20cf45 100755
--- a/scripts/vyatta-op-dns-forwarding.pl
+++ b/scripts/vyatta-op-dns-forwarding.pl
@@ -67,8 +67,24 @@ sub get_nameserver_stats {
$show_stats_output .= "Nameserver statistics\n";
$show_stats_output .= "---------------------\n";
- my @grepped_lines = `grep ': server' $dnsmasq_log`;
+ #To show overridden domain servers seperately, we need to compare IPs
+ #configured for the domain overrides in the config with the stats.
+
+ my $vyatta_config = new Vyatta::Config;
+ $vyatta_config->setLevel("service dns forwarding");
+
+ my @domains = $vyatta_config->listOrigNodes("domain");
+ my @domain_servers_list;
+ #build a list of servers that are overriding global nameservers
+ if (@domains) {
+ foreach my $domain (@domains) {
+ push(@domain_servers_list, $vyatta_config->returnOrigValue("domain $domain server"));
+ }
+ }
+ my $found_overrides = 0;
+ my $show_stats_overrides;
+ my @grepped_lines = `grep ': server' $dnsmasq_log`;
foreach my $lines (@grepped_lines) {
my @each_line = split(/\s+/, $lines);
my $nameserver_word = $each_line[5];
@@ -79,9 +95,17 @@ sub get_nameserver_stats {
my $queries_sent = $queries_sent_split[0];
my $queries_retried_failed = $each_line[12];
- $show_stats_output .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n";
-
+ if (grep {$_ eq $nameserver}@domain_servers_list) {
+ if (!$found_overrides) {
+ $found_overrides = 1;
+ $show_stats_overrides .= "\nDomain Override Servers\n\n";
+ }
+ $show_stats_overrides .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n";
+ } else {
+ $show_stats_output .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n";
+ }
}
+ $show_stats_output .= $show_stats_overrides;
}
sub print_stats {
@@ -162,17 +186,36 @@ sub get_dns_nameservers {
$show_nameservers_output .= "-----------------------------------------------\n";
$show_nameservers_output .= " Nameservers configured for DNS forwarding\n";
$show_nameservers_output .= "-----------------------------------------------\n";
+
+ my $line_flag;
+ ## server=/test.com/1.1.1.1
foreach my $line (@dnsmasq_conf_nameservers) {
my @split_line = split(/=/, $line);
my @nameserver_array = split(/\s+/, $split_line[1]);
my $nameserver = $nameserver_array[0];
+ my $domain;
+ my @domain_tokens;
+
+ if ($nameserver_array[2] eq "domain-override")
+ {
+ #$nameserver has /test.com/1.1.1.1, seperate it.
+ @domain_tokens = split(/\//, $nameserver);
+ if (!defined($line_flag)) {
+ $line_flag = 1;
+ $show_nameservers_output .= "\n";
+ $show_nameservers_output .= "Domain Overrides\n";
+ $show_nameservers_output .= "\n";
+ }
+ }
$active_nameservers[$active_nameserver_count] = $nameserver;
$active_nameserver_count++;
my $nameserver_via = $nameserver_array[2];
if (@nameserver_array > 3){
my $dhcp_interface = $nameserver_array[3];
$show_nameservers_output .= "$nameserver available via '$nameserver_via $dhcp_interface'\n";
- } else {
+ } elsif (@domain_tokens) {
+ $show_nameservers_output .= "$domain_tokens[1] uses $domain_tokens[2] via '$nameserver_via'\n";
+ } else {
$show_nameservers_output .= "$nameserver available via '$nameserver_via'\n";
}
}
diff --git a/scripts/vyatta-reboot.pl b/scripts/vyatta-reboot.pl
index f738986..3dc212c 100755
--- a/scripts/vyatta-reboot.pl
+++ b/scripts/vyatta-reboot.pl
@@ -116,7 +116,7 @@ if ($action eq "reboot") {
do_reboot($login);
} else {
if (defined($ENV{VYATTA_PROCESS_CLIENT} && $ENV{VYATTA_PROCESS_CLIENT} eq 'gui2_rest') ||
- prompt("Proceed with reboot? (Yes/No) [No] ", -yn1d=>"n")) {
+ prompt("Proceed with reboot? (Yes/No) [No] ", -ynd=>"n")) {
do_reboot($login);
} else {
print "Reboot canceled\n";