summaryrefslogtreecommitdiff
path: root/scripts/system
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/system')
-rwxr-xr-xscripts/system/vyatta_update_ntp.pl115
-rwxr-xr-xscripts/system/vyatta_update_resolv.pl15
2 files changed, 0 insertions, 130 deletions
diff --git a/scripts/system/vyatta_update_ntp.pl b/scripts/system/vyatta_update_ntp.pl
deleted file mode 100755
index 78a617bc..00000000
--- a/scripts/system/vyatta_update_ntp.pl
+++ /dev/null
@@ -1,115 +0,0 @@
-#! /usr/bin/perl
-
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# **** End License ****
-
-# Filter ntp.conf - remove old servers and add current ones
-
-use strict;
-use lib "/opt/vyatta/share/perl5";
-use Vyatta::Config;
-use NetAddr::IP;
-use Getopt::Long;
-
-my $dhclient_script = 0;
-
-GetOptions("dhclient-script=i" => \$dhclient_script,
-);
-
-sub ntp_format {
- my ($cidr_or_host) = @_;
- my $ip = NetAddr::IP->new($cidr_or_host);
- if (defined($ip)) {
- my $address = $ip->addr();
- my $mask = $ip->mask();
-
- if (
- ($ip->version() == 6 && $ip->masklen() == 128)
- || ($ip->version() == 4 && $ip->masklen() == 32)
- ) {
- return "$address";
- } else {
- return "$address mask $mask";
- }
- } else {
- return undef;
- }
-}
-
-my @ntp;
-if (-e '/etc/ntp.conf') {
- open (my $file, '<', '/etc/ntp.conf')
- or die("$0: Error! Unable to open '/etc/ntp.conf' for input: $!\n");
- @ntp = <$file>;
- close ($file);
-}
-
-open (my $output, '>', '/etc/ntp.conf')
- or die("$0: Error! Unable to open '/etc/ntp.conf' for output: $!\n");
-
-my $cfg = new Vyatta::Config;
-$cfg->setLevel("system ntp");
-
-foreach my $line (@ntp) {
- if ($line =~ /^# VyOS CLI configuration options/) {
- print $output $line;
- print $output "\n";
- last;
- } else {
- print $output $line;
- }
-}
-
-my @servers;
-my @clients;
-
-if ($dhclient_script == 1) {
- @servers = $cfg->listOrigNodes("server");
- @clients = $cfg->returnOrigValues("allow-clients address");
-} else {
- @servers = $cfg->listNodes("server");
- @clients = $cfg->returnValues("allow-clients address");
-}
-
-if (scalar(@servers) > 0) {
- print $output "# Servers\n\n";
- foreach my $server (@servers) {
- my $server_addr = ntp_format($server);
- if (defined($server_addr)) {
- print $output "server $server_addr iburst";
- for my $property (qw(dynamic noselect preempt prefer)) {
- if ($dhclient_script == 1) {
- print $output " $property" if ($cfg->existsOrig("server $server $property"));
- } else {
- print $output " $property" if ($cfg->exists("server $server $property"));
- }
- }
- print $output "\nrestrict $server_addr nomodify notrap nopeer noquery\n";
- }
- }
- print $output "\n";
-}
-
-if (scalar(@clients) > 0) {
- print $output "# Clients\n\n";
- foreach my $client (@clients) {
- my $address = ntp_format($client);
- print $output "restrict $address nomodify notrap nopeer\n";
- }
- print $output "\n";
-}
-
-exit 0;
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl
index 51617fce..de09a760 100755
--- a/scripts/system/vyatta_update_resolv.pl
+++ b/scripts/system/vyatta_update_resolv.pl
@@ -30,7 +30,6 @@ use Vyatta::Config;
my $dhclient_script = 0;
my $config_mode = 0;
-my $ntp_config = 0;
GetOptions("dhclient-script=i" => \$dhclient_script,
"config-mode=i" => \$config_mode,
@@ -45,7 +44,6 @@ my $disable_dhcp_nameservers = undef;
if ($config_mode == 1) {
$disable_dhcp_nameservers = $vc->exists('disable-dhcp-nameservers');
- $ntp_config = $vc->exists('ntp server');
} else {
$disable_dhcp_nameservers = $vc->existsOrig('disable-dhcp-nameservers');
}
@@ -53,7 +51,6 @@ if ($config_mode == 1) {
if ($dhclient_script == 1) {
@search_domains = $vc->returnOrigValues('domain-search domain');
$domain_name = $vc->returnOrigValue('domain-name');
- $ntp_config = $vc->existsOrig('ntp server');
} else {
@search_domains = $vc->returnValues('domain-search domain');
$domain_name = $vc->returnValue('domain-name');
@@ -132,7 +129,6 @@ if ($domain_name && length($domain_name) > 0) {
if (($dhclient_script == 1) || ($config_mode == 1)) {
my @current_dhcp_nameservers;
- my $restart_ntp = 0;
# code below to add new name-servers received from dhcp client, but only if disable-dhcp-nameservers
# hasn't been enabled.
@@ -168,7 +164,6 @@ if (($dhclient_script == 1) || ($config_mode == 1)) {
or die "$! error trying to overwrite";
print $rf "#nameserver written by vyatta_update_resolv.pl (dhcp)\nnameserver\t$ns\n";
close $rf;
- $restart_ntp = 1;
}
}
}
@@ -206,7 +201,6 @@ if (($dhclient_script == 1) || ($config_mode == 1)) {
$cmd = "sed -i -n '/nameserver\t$dhcpnameserver/".'{n;x;d;};x;1d;p;${x;p;}'."' /etc/resolv.conf";
}
system($cmd);
- $restart_ntp = 1;
}
} else {
for my $dhcpnameserver (@dhcp_nameservers_in_resolvconf) {
@@ -225,18 +219,9 @@ if (($dhclient_script == 1) || ($config_mode == 1)) {
$cmd = "sed -i -n '/nameserver\t$dhcpnameserver/".'{n;x;d;};x;1d;p;${x;p;}'."' /etc/resolv.conf";
}
system($cmd);
- $restart_ntp = 1;
}
}
}
- if ($restart_ntp == 1) {
- # this corresponds to what is done in name-server/node.def as a fix for bug 1300
- if ($ntp_config == 1) {
- system("sudo /opt/vyatta/sbin/vyatta_update_ntp.pl --dhclient-script $dhclient_script");
- my $cmd_ntp_restart = "if [ -f /etc/ntp.conf ] && grep -q '^server' /etc/ntp.conf; then /usr/sbin/invoke-rc.d ntp restart >&/dev/null; fi &";
- system($cmd_ntp_restart);
- }
- }
}
# The following will re-write '/etc/resolv.conf' line by line,