diff options
author | Daniil Baturin <daniil@vyos.io> | 2021-01-08 01:39:42 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2021-01-08 01:45:34 +0200 |
commit | ac2586bc6471a141203e21ec3bfe97bfbcad6672 (patch) | |
tree | dd4f7d6c84e00e18e025a8f4ca43eeefa7731832 | |
parent | cc36c93479d954ac6ab5454c2d25e86edbc57c61 (diff) | |
download | vyatta-cfg-system-ac2586bc6471a141203e21ec3bfe97bfbcad6672.tar.gz vyatta-cfg-system-ac2586bc6471a141203e21ec3bfe97bfbcad6672.zip |
T671: remove apparently unused scripts.
-rw-r--r-- | Makefile.am | 11 | ||||
-rwxr-xr-x | scripts/is_port_available.pl | 14 | ||||
-rwxr-xr-x | scripts/netplug/linkdown/dhclient | 65 | ||||
-rwxr-xr-x | scripts/netplug/linkup/dhclient | 64 | ||||
-rwxr-xr-x | scripts/restricted-shell | 11 | ||||
-rwxr-xr-x | scripts/system/irq-affinity.pl | 382 | ||||
-rwxr-xr-x | scripts/system/vyatta_check_username.pl | 87 | ||||
-rwxr-xr-x | scripts/system/vyatta_update_console.pl | 150 | ||||
-rwxr-xr-x | scripts/system/vyatta_update_logrotate.pl | 51 | ||||
-rwxr-xr-x | scripts/system/vyatta_update_syslog.pl | 169 | ||||
-rwxr-xr-x | scripts/telnetd.init | 90 | ||||
-rwxr-xr-x | scripts/vyatta-bridgegroup-depedency.pl | 91 | ||||
-rwxr-xr-x | scripts/vyatta-functions | 41 | ||||
-rwxr-xr-x | scripts/vyatta-update-grub.pl | 278 | ||||
-rw-r--r-- | scripts/vyos-popcon.pl | 155 | ||||
-rw-r--r-- | tests/interface.pl | 52 | ||||
-rw-r--r-- | tests/isip.pl | 23 |
17 files changed, 0 insertions, 1734 deletions
diff --git a/Makefile.am b/Makefile.am index c5f7dfac..a2a1a087 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,9 +21,6 @@ initd_SCRIPTS += etc/init.d/vyatta-config-reboot-params checkparamsonreboot_SCRIPTS += scripts/check-params-on-reboot.d/ipv6_disable_blacklist bin_SCRIPTS += scripts/progress-indicator -bin_SCRIPTS += scripts/vyatta-functions -bin_SCRIPTS += scripts/restricted-shell -bin_SCRIPTS += scripts/vyos-popcon.pl bin_sudo_users_SCRIPTS += scripts/vyatta-tunnel-dhcp.pl sbin_SCRIPTS += scripts/vyatta-update-tunnel.pl @@ -34,14 +31,9 @@ sbin_SCRIPTS += scripts/rl-system.init sbin_SCRIPTS += scripts/vyatta-grub-setup sbin_SCRIPTS += scripts/standalone_root_pw_reset sbin_SCRIPTS += scripts/vyatta-passwd-sync -sbin_SCRIPTS += scripts/system/vyatta_check_username.pl -sbin_SCRIPTS += scripts/system/vyatta_check_domainname.pl sbin_SCRIPTS += scripts/system/vyatta_interface_rescan -sbin_SCRIPTS += scripts/system/vyatta_update_logrotate.pl sbin_SCRIPTS += scripts/system/vyatta_update_sysctl.pl -sbin_SCRIPTS += scripts/system/irq-affinity.pl sbin_SCRIPTS += scripts/snmp/if-mib-alias -sbin_SCRIPTS += scripts/telnetd.init sbin_SCRIPTS += scripts/vyatta-interfaces.pl sbin_SCRIPTS += scripts/vyatta-address sbin_SCRIPTS += scripts/vyatta-tunnel-cleanup @@ -53,10 +45,7 @@ sbin_SCRIPTS += scripts/install/install-image-new sbin_SCRIPTS += scripts/install/install-image-existing sbin_SCRIPTS += scripts/install/install-postinst-new sbin_SCRIPTS += scripts/install/install-image -sbin_SCRIPTS += scripts/vyatta-bridgegroup-depedency.pl sbin_SCRIPTS += scripts/vyatta-dhcpv6-client.pl -sbin_SCRIPTS += scripts/vyatta-update-grub.pl -sbin_SCRIPTS += scripts/is_port_available.pl sbin_SCRIPTS += scripts/vyos-persistpath sbin_PROGRAMS = src/valid_address diff --git a/scripts/is_port_available.pl b/scripts/is_port_available.pl deleted file mode 100755 index acf3e6e3..00000000 --- a/scripts/is_port_available.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/perl -# Check to see if the supplied IPv4 or IPv6 address is an existing local address - -use strict; -use lib "/opt/vyatta/share/perl5"; -use Vyatta::Misc; - -my $port = $ARGV[0]; - -if(!defined($port) || !is_port_available($port)) { - exit 1; -} else { - exit 0; -}
\ No newline at end of file diff --git a/scripts/netplug/linkdown/dhclient b/scripts/netplug/linkdown/dhclient deleted file mode 100755 index 555ff913..00000000 --- a/scripts/netplug/linkdown/dhclient +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -# -# Module: dhclient -# -# **** 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. -# -# A copy of the GNU General Public License is available as -# `/usr/share/common-licenses/GPL' in the Debian GNU/Linux distribution -# or on the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'. -# You can also obtain it by writing to the Free Software Foundation, -# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: November 2008 -# Description: Script to release lease on link down -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Vyatta::Config; -use Vyatta::Misc; - -use strict; -use warnings; - -sub stop_dhclient { - my $intf = shift; - my $dhcp_daemon = '/sbin/dhclient'; - my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = Vyatta::Misc::generate_dhclient_intf_files($intf); - my $release_cmd = "sudo $dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null;"; - $release_cmd .= "sudo rm -f $intf_process_id_file 2> /dev/null"; - system ($release_cmd); -} - - -# -# main -# - -my $dev=shift; - -# only do this if interface is configured to use dhcp for getting IP address -if (Vyatta::Misc::is_dhcp_enabled($dev, "outside_cli")) { - # do a dhcp lease release for interface - stop_dhclient($dev); -} - -exit 0; - -# end of file - diff --git a/scripts/netplug/linkup/dhclient b/scripts/netplug/linkup/dhclient deleted file mode 100755 index 8e50715f..00000000 --- a/scripts/netplug/linkup/dhclient +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/perl -# -# Module: dhclient -# -# **** 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. -# -# A copy of the GNU General Public License is available as -# `/usr/share/common-licenses/GPL' in the Debian GNU/Linux distribution -# or on the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'. -# You can also obtain it by writing to the Free Software Foundation, -# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: November 2008 -# Description: Script to renew lease on link up -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Vyatta::Config; -use Vyatta::Misc; - -use strict; -use warnings; - -sub run_dhclient { - my $intf = shift; - my $dhcp_daemon = '/sbin/dhclient'; - my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = Vyatta::Misc::generate_dhclient_intf_files($intf); - my $cmd = "sudo $dhcp_daemon -pf $intf_process_id_file -x $intf 2> /dev/null; sudo rm -f $intf_process_id_file 2> /dev/null;"; - $cmd .= "sudo $dhcp_daemon -q -nw -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file $intf 2> /dev/null &"; - system ($cmd); -} - -# -# main -# - -my $dev=shift; - -# only do this if interface is configured to use dhcp for getting IP address -if (Vyatta::Misc::is_dhcp_enabled($dev, "outside_cli")) { - # do a dhcp lease renew for interface - run_dhclient($dev); -} - -exit 0; - -# end of file - diff --git a/scripts/restricted-shell b/scripts/restricted-shell deleted file mode 100755 index ffcbb53b..00000000 --- a/scripts/restricted-shell +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# != 0 ]; then - echo "Remote command execution is not allowed for operator level users" - args=($@) - args_str=$(IFS=" " ; echo "${args[*]}") - logger "Operator level user $USER attempted remote command execution: $args_str" - exit 1 -fi - -exec vbash diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl deleted file mode 100755 index de0c3099..00000000 --- a/scripts/system/irq-affinity.pl +++ /dev/null @@ -1,382 +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) 2009,2010 Vyatta, Inc. -# All Rights Reserved. -# -# **** End License **** -# -use warnings; -use strict; -use Sys::Syslog qw(:standard :macros); - -my $PATH_SYS_SYSTEM = "/sys/devices/system"; -my $PATH_SYS_CPU0 = $PATH_SYS_SYSTEM . "/cpu/cpu0"; - -die "Usage: $0 ifname {auto | mask} { debug }\n" if ($#ARGV < 1); - -my ($ifname, $mask, $debug) = @ARGV; - -die "Error: Interface $ifname does not exist\n" - unless -d "/sys/class/net/$ifname"; - -my $logopt = defined($debug) ? "perror" : ""; -openlog("irq-affinity", $logopt, LOG_LOCAL0); - -my ($cpus, undef, $threads) = cpuinfo(); - -if ($mask eq 'auto') { - affinity_auto($ifname); -} else { - affinity_mask($ifname, $mask); -} - -exit 0; - -# Get current irq assignments by reading /proc/interrupts -# returns reference to hash of interrupt infromation for given interface -# i.e. {'eth1'} => 22, {'eth1-tx-1'} => 31, ... -# -# Code based on parsing in irqbalance program -# -# Format of /proc/interrupts is: -# -# CPU0 CPU1 -# 72: 1637 0 PCI-MSI-edge eth3 -sub irqinfo { - my $ifname = shift; - my $irqmap; - - open( my $f, '<', "/proc/interrupts" ) - or die "Can't read /proc/interrupts"; - - # first line is the header we don't need - <$f>; - - while (<$f>) { - chomp; - - # lines with letters in front are special, like NMI count. - # - # First column is IRQ number (and colon) - # after that match as many entries with digits - last unless /^\s*(\d+):\s/; - my $irq = $1; - - my @cols = split; - - # skip the irq number and all counts - do { - shift @cols; - } while ($cols[0] =~ /^\d+$/); - - foreach my $name ( @cols ) { - $name =~ s/,$//; - - next unless ($name eq $ifname || $name =~ /^$ifname-/ ); - - $irqmap->{$name} = $irq; - } - } - close $f; - - return $irqmap; -} - -# compute number of bits set -sub hweight { - my $bits = shift; - my $count = 0; - - for (; $bits > 0; $bits >>= 1) { - ++$count if ($bits & 1); - } - return $count; -} - -# count the bits set in a mapping file -sub path_sibling { - my $path = shift; - my $result = 0; - - open (my $f, '<', $path) - or die "can't open $path : $!"; - - my $line = <$f>; - close $f; - chomp $line; - - for my $mask (split(/,/, $line)) { - $result += hweight(hex($mask)); - } - - return $result; -} - -# Determine number of cpu topology information -# -# This algorithm is based on the command lscpu from util-linux -# it cases like multiple socket, offline cpus, etc -sub cpuinfo { - my $cpu = 0; - - # XXX doesn't handle offline CPU's... - while ( -e $PATH_SYS_SYSTEM . '/cpu/cpu' . $cpu ) { - ++$cpu; - } - - my $thread = path_sibling($PATH_SYS_CPU0 . '/topology/thread_siblings'); - my $core = path_sibling($PATH_SYS_CPU0 . '/topology/core_siblings') / $thread; - my $socket = $cpu / $core / $thread; - - syslog(LOG_DEBUG, "cpus=%d cores=%d threads=%d sockets=%d\n", - $cpu, $core, $thread, $socket); - - return ($cpu, $core, $thread); -} - -# Set affinity value for a irq -sub set_affinity { - my ( $ifname, $irq, $mask ) = @_; - my $smp_affinity = "/proc/irq/$irq/smp_affinity"; - - syslog(LOG_DEBUG, "%s: irq %d affinity set to 0x%x", $ifname, $irq, $mask); - - open( my $f, '>', $smp_affinity ) - or die "Can't open: $smp_affinity : $!\n"; - printf {$f} "%x\n", $mask; - close $f; -} - -# set Receive Packet Steering mask -sub set_rps { - my ( $ifname, $q, $mask ) = @_; - - # ignore if older kernel without RPS - my $rxq = "/sys/class/net/$ifname/queues"; - return unless ( -d $rxq ); - - syslog(LOG_INFO, "%s: receive queue %d cpus set to 0x%x", - $ifname, $q, $mask); - - my $rps_cpus = "$rxq/rx-$q/rps_cpus"; - open( my $f, '>', $rps_cpus ) - or die "Can't open: $rps_cpus : $!\n"; - printf {$f} "%x\n", $mask; - close $f; -} - -# Check if the current if this cpu is in the banned mask -# Uses environment variable VYATTA_IRQAFFINITY_BANNED_CPUS -# to mask cpus which irq affinity script should ignore -sub skip_cpu { - my $cpu = shift; - my $banned = $ENV{'VYATTA_IRQAFFINITY_BANNED_CPUS'}; - - return unless defined($banned); # false - - return ((1 << $cpu) & hex($banned)) != 0; -} - -# For multi-queue NIC choose next cpu to be on next core -# XXX doesn't handle offline CPU's... -sub next_cpu { - my $origcpu = shift; - my $cpu = $origcpu; - - do { - $cpu += $threads; - if ( $cpu >= $cpus ) { - # wraparound to next thread on core 0 - $cpu = ($cpu + 1) % $threads; - } - } while ($cpu != $origcpu && skip_cpu($cpu)); - - return $cpu; -} - -# Get cpu to assign for the queues for single queue nic -sub choose_cpu { - my $ifname = shift; - - # For single-queue nic choose IRQ based on name - # Ideally should make decision on least loaded CPU - my ($ifunit) = ($ifname =~ m/^[a-z]*(\d+)$/); - die "can't find number for $ifname\n" - unless defined($ifunit); - - # Give the load first to one CPU of each hyperthreaded core, then - # if there are enough NICs, give the load to the other CPU of - # each core. - # XXX doesn't handle offline CPU's... - my $ht_wrap = (($ifunit * $threads) / $cpus) % $threads; - my $cpu = ((($ifunit * $threads) + $ht_wrap) % $cpus); - - $cpu = next_cpu($cpu) if skip_cpu($cpu); - return $cpu; -} - -# Assignment for multi-queue NICs -sub assign_multiqueue { - my $ifname = shift; - my $irqmap = shift; - my $numq = scalar(@_); - my $cpu; - - if ($numq == 1) { - # This is a single-queue NIC using the multi-queue naming - # format. In this case, we use the same algorithm to select - # the CPU as we use for standard single-queue NICs. This - # algorithm spreads the work of different NICs accross - # different CPUs. - - $cpu = choose_cpu($ifname); - } else { - # For multi-queue nic's always starts with CPU 0 - # This is less than ideal when there are more core's available - # than number of queues (probably should barber pole); - # but the Intel IXGBE needs CPU 0 <-> queue 0 - # because of flow director bug. - - $cpu = 0; - } - - foreach my $name (sort @_) { - my $irq = $irqmap->{$name}; - - die "Can't find irq in map for $name\n" unless $irq; - - syslog(LOG_INFO, "%s: assign %s to cpu %d", - $ifname, $name, $cpu ); - - # Assign CPU affinity for both IRQs - set_affinity( $ifname, $irq, 1 << $cpu ); - - # TODO use RPS to steer data if cores > queues? - $cpu = next_cpu($cpu); - } -} - -# Affinity assignment function for single-queue NICs. The strategy -# here is to just spread the interrupts of different NICs evenly -# across all CPUs. That is the best we can do without monitoring the -# load and traffic patterns. So we just directly map the NIC unit -# number into a CPU number. -sub assign_single { - my ( $ifname, $irq ) = @_; - my $cpu = choose_cpu($ifname); - - syslog(LOG_INFO,"%s: assign irq %d to cpu %d", $ifname, $irq, $cpu ); - - set_affinity( $ifname, $irq, 1 << $cpu ); - - if ($threads > 1) { - # Use both threads on this cpu if hyperthreading - my $mask = ((1 << $threads) - 1) << $cpu; - set_rps($ifname, 0, $mask); - } - # MAYBE - Use all cpu's if no HT -} - -# Mask must contain at least one CPU and -# no bits outside of range of available CPU's -sub check_mask { - my ($ifname, $name, $mask) = @_; - my $m = hex($mask); - - die "$ifname: $name mask $mask has no bits set\n" - if ($m == 0); - - die "$ifname: $name mask $mask too large for number of CPU's: $cpus\n" - if ($m >= 1 << $cpus); -} - -# Set affinity (and RPS) based on mask -sub affinity_mask { - my ($ifname, $mask) = @_; - - # match on <hex> or <hex>,<hex> - unless ($mask =~ /^([0-9a-f]+)(|,([0-9a-f]+))$/) { - die "$ifname: irq mask $mask is not a valid affinity mask\n" - } - - my $irqmsk = $1; - my $rpsmsk = $3; - - check_mask($ifname, "irq", $irqmsk); - check_mask($ifname, "rps", $rpsmsk) if $rpsmsk; - - my $irqmap = irqinfo($ifname); - while (my ($name, $irq) = each (%{$irqmap})) { - syslog(LOG_INFO, "%s: assign irq %d mask %s", $name, $irq, $irqmsk); - set_affinity($name, $irq, hex($irqmsk)); - } - - set_rps($ifname, 0, hex($rpsmsk)) if $rpsmsk; -} - -# The auto strategy involves trying to achieve the following goals: -# -# - Spread the receive load among as many CPUs as possible. -# -# - For all multi-queue NICs in the system that provide both tx and -# rx queues, keep all of the queues that share the same queue -# number on same CPUs. I.e. tx and rx queue 0 of all such NICs -# should interrupt one CPU; tx and rx queue 1 should interrupt a -# different CPU, etc. -# -# - If hyperthreading is supported and enabled, avoid assigning -# queues to both CPUs of a hyperthreaded pair if there are enough -# CPUs available to do that. -sub affinity_auto { - my $ifname = shift; - - my $irqmap = irqinfo($ifname); - my @irqnames = keys %{$irqmap}; - my $numirq = scalar(@irqnames); - - # Figure out what style of irq naming is being used - if ( $numirq == 1 ) { - my $irq = $irqmap->{$ifname}; - assign_single( $ifname, $irq) if $irq; - } elsif ($numirq > 1) { - # Special case for paired Rx and Tx - my @mirq = grep { /^$ifname-rx-/ } @irqnames; - my $num_mirq = scalar(@mirq); - if ( $num_mirq > 0 ) { - assign_multiqueue( $ifname, $irqmap, @mirq ); - - @mirq = grep { /^$ifname-tx-/ } @irqnames; - assign_multiqueue( $ifname, $irqmap, @mirq ); - return; - } - - # Normal case for single irq per queue - @mirq = grep { /^$ifname-/ } @irqnames; - $num_mirq = scalar(@mirq); - if ( $num_mirq > 0 ) { - assign_multiqueue( $ifname, $irqmap, @mirq ); - return; - } - - # Netxen thought up yet another convention - @mirq = grep { /^$ifname\[/ } @irqnames; - if ( $#mirq > 0 ) { - assign_multiqueue( $ifname, $irqmap, @mirq ); - return; - } - - syslog(LOG_ERR, "%s: Unknown multiqueue irq naming: %s\n", $ifname, - join(' ', @irqnames)); - } -} diff --git a/scripts/system/vyatta_check_username.pl b/scripts/system/vyatta_check_username.pl deleted file mode 100755 index 9ecc42db..00000000 --- a/scripts/system/vyatta_check_username.pl +++ /dev/null @@ -1,87 +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) 2010 Vyatta, Inc. -# All Rights Reserved. -# -# **** End License **** - -use strict; -use warnings; - -my $passwdFile = '/etc/passwd'; - -# Lookup user in password file which may not give same -# result as getpw* which uses NSS -sub finduser { - my $user = shift; - my $uid; - - open( my $f, '<', $passwdFile ) - or die "Can't open $passwdFile: $!"; - - while (<$f>) { - chomp; - my ( $name, undef, $id ) = split /:/; - - next unless ( $name eq $user ); - $uid = $id; - last; - } - close $f; - - return $uid; -} - -foreach my $user (@ARGV) { - # enforce recommendations from useradd man page - - # Debian, the only constraints are that usernames must neither start - # with a dash (-) nor contain a colon (:) or a whitespace (space: , end - # of line: \n, tabulation: \t, etc.). Note that using a slash (/) may - # break the default algorithm for the definition of the users home - # directory. - die "$user : illegal characters in username\n" - unless ($user =~ /^\w[^ \t\n\r\v\f:\/]*$/); - - # Usernames may only be up to 32 characters long. - die "$user: username may only be up to 32 characters long\n" - if (length($user) > 32); - - # It is usually recommended to only use usernames that begin with a - # lower case letter or an underscore followed by lower case letters, - # digits, underscores, or dashes. They can end with a dollar sign. - # In regular expression terms: [a-z_][a-z0-9_-]*[$]? - warn "$user: username contains unusual characters\n" - . " should only contain lower case letters, digits, underscores or dashes\n" - unless ($user =~ /^[a-z_][a-z0-9_-]*\$?$/); - - # User does not exist in system, its okay - my $uid = getpwnam($user); - next unless defined($uid) and $uid ne "1001"; - - # System accounts should not be listed in vyatta configuration - # 1000 is SYS_UID_MIN - die "$user : account is already reserved for system use\n" - if ($uid > 0 && $uid < 1000); - - my $pwuid = finduser($user); - - die "$user : account exists but is not local (change on server)\n" - unless defined ($pwuid); - - die "$user : exists but has different uid on local versus remote\n" - unless ($pwuid eq $uid); -} - -exit 0; diff --git a/scripts/system/vyatta_update_console.pl b/scripts/system/vyatta_update_console.pl deleted file mode 100755 index 099a8fc4..00000000 --- a/scripts/system/vyatta_update_console.pl +++ /dev/null @@ -1,150 +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) 2010 Vyatta, Inc. -# All Rights Reserved. -# -# **** End License **** - -# Update console configuration in systemd and grub based on Vyatta configuration - -use strict; -use warnings; - -use lib "/opt/vyatta/share/perl5"; -use Vyatta::Config; -use File::Compare; -use File::Copy; -use experimental 'smartmatch'; - -die "$0 expects no arguments\n" if (@ARGV); - -# if file is unchanged, do nothing and return false -# otherwise update to new version -sub update { - my ($old, $new) = @_; - - if (compare($old, $new) != 0) { - move($new, $old) - or die "Can't move $new to $old"; - return 1; - } else { - unlink($new); - return; - } -} - -sub update_getty{ - my $directory = "/etc/systemd/system"; - my $config = new Vyatta::Config; - $config->setLevel("system console device"); - my @ttys; - - foreach my $tty ($config->listNodes()) { - push(@ttys, "serial-getty\@$tty.service"); - } - - opendir DIR, $directory or die "Couldn't open dir '$directory': $!"; - while (my $file = readdir(DIR)) { - next unless ($file =~ /^serial-getty/); - if ( not $file ~~ @ttys ) { - system("systemctl stop $file"); - if (-e "$directory/getty.target.wants/$file") { - unlink "$directory/getty.target.wants/$file" - or die "Failed to remove file $file: $!\n"; - } - if (-e "$directory/$file") { - unlink "$directory/$file" - or die "Failed to remove file $file: $!\n"; - } - system("systemctl daemon-reload"); - } - } - closedir DIR; - - foreach my $tty ($config->listNodes()) { - my $SGETTY = "/lib/systemd/system/serial-getty\@.service"; - my $TMPGETTY = "/etc/systemd/system/serial-getty\@$tty.service"; - my $SYMGETTY = "/etc/systemd/system/getty.target.wants/serial-getty\@$tty.service"; - - open(my $sgetty, '<', $SGETTY) - or die "Can't open $SGETTY: $!"; - - open(my $tmp, '>', $TMPGETTY) - or die "Can't open $TMPGETTY: $!"; - - my $speed = $config->returnValue("$tty speed"); - if ($tty =~ /^hvc\d/) { - $speed = 38400 unless $speed; - } else { - $speed = 115200 unless $speed; - } - - while (<$sgetty>) { - if (/^ExecStart=/) { - $_ =~ s/115200,38400,9600/$speed/g; - } - print {$tmp} $_; - } - close $sgetty; - close $tmp; - symlink("$TMPGETTY","$SYMGETTY"); - system("systemctl daemon-reload"); - if ( system("systemctl status serial-getty\@$tty.service 2>&1 > /dev/null")) { - system("systemctl start serial-getty\@$tty.service"); - } else { - system("/bin/stty -F /dev/$tty $speed cstopb"); - } - } -} - -my $GRUBCFG = "/boot/grub/grub.cfg"; -my $GRUBTMP = "/tmp/grub.cfg.$$"; - -# For existing serial line change speed (if necessary) -# Only applys to ttyS0 -sub update_grub { - return unless (-f $GRUBCFG); - - my $config = new Vyatta::Config; - $config->setLevel("system console device"); - return unless $config->exists("ttyS0"); - - my $speed = $config->returnValue("ttyS0 speed"); - $speed = "115200" unless defined($speed); - - open(my $grub, '<', $GRUBCFG) - or die "Can't open $GRUBCFG: $!"; - - open(my $tmp, '>', $GRUBTMP) - or die "Can't open $GRUBTMP: $!"; - - while (<$grub>) { - if (/^serial /) { - print {$tmp} "serial --unit=0 --speed=$speed\n"; - } elsif (/^(.* console=ttyS0),[0-9]+(.*)$/) { - print {$tmp} "$1,$speed$2\n"; - } else { - print {$tmp} $_; - } - } - close $grub; - close $tmp; - - update($GRUBCFG, $GRUBTMP); -} - -update_getty; -update_grub; - -exit 0; diff --git a/scripts/system/vyatta_update_logrotate.pl b/scripts/system/vyatta_update_logrotate.pl deleted file mode 100755 index 8620ede1..00000000 --- a/scripts/system/vyatta_update_logrotate.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl - -# Exit code: -# 0 - success -# 1 - missing parameter -# 2 - invalid files or size parameters -# 3 - unable to write logrotate config - -use strict; - -my $cfg_dir = "/opt/vyatta/etc/logrotate"; -my $file = "global"; -my $log_file = "/var/log/messages"; -my $log_conf = "${cfg_dir}/$file"; -if ($#ARGV == 3) { - $file = shift; - $log_file = "/var/log/user/$file"; - $log_conf = "${cfg_dir}/file_$file"; -} -my $files = shift; -my $size = shift; -my $set = shift; - -if (!defined($files) || !defined($size) || !defined($set)) { - exit 1; -} - -if (!($files =~ m/^\d+$/) || !($size =~ m/^\d+$/)) { - exit 2; -} - -# just remove it and make a new one below -# (the detection mechanism in XORP doesn't work anyway) -unlink $log_conf; - -open my $out, '>', $log_conf - or exit 3; -if ($set == 1) { - print $out <<EOF; -$log_file { - missingok - notifempty - create - rotate $files - size=${size}k -} -EOF -} -close $out; - -exit 0; diff --git a/scripts/system/vyatta_update_syslog.pl b/scripts/system/vyatta_update_syslog.pl deleted file mode 100755 index 37d017e3..00000000 --- a/scripts/system/vyatta_update_syslog.pl +++ /dev/null @@ -1,169 +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 **** - -# Update /etc/rsyslog.d/vyatta-log.conf -# Exit code: 0 - update -# 1 - no change or error - -use strict; -use lib "/opt/vyatta/share/perl5"; -use Vyatta::Config; -use File::Basename; -use File::Compare; -use File::Temp qw/ tempfile /; - -my $SYSLOG_CONF = '/etc/rsyslog.d/vyatta-log.conf'; -my $SYSLOG_TMPL = "/tmp/rsyslog.conf.XXXXXX"; -my $MESSAGES = '/var/log/messages'; -my $CONSOLE = '/dev/console'; -my $LOGROTATE_CFG_DIR = '/opt/vyatta/etc/logrotate'; - -my %entries = (); - -die "$0 expects no arguments\n" if (@ARGV); - -sub add_target_selector { - my ( $selector, $target ) = @_; - - $entries{$target}{selector} = [] unless $entries{$target}{selector}; - push @{ $entries{$target}{selector} }, $selector; -} - -sub set_target_param { - my ( $config, $level, $target, $param ) = @_; - my $path = "$level archive $param"; - - if (! $config->exists($path)) { - my @tmpl = $config->parseTmpl($path); - $entries{$target}{$param} = $tmpl[2]; - } else { - $entries{$target}{$param} = $config->returnValue($path); - } -} - -sub get_target_param { - my ( $target, $param ) = @_; - return $entries{$target}{$param}; -} - -# This allows overloading local values in CLI -my %facmap = ( - 'all' => '*', - 'protocols' => 'local7', -); - -# This builds a data structure that maps from target -# to selector list for that target -sub read_config { - my ( $config, $level, $target ) = @_; - - foreach my $facility ( $config->listNodes("$level facility") ) { - my $loglevel = $config->returnValue("$level facility $facility level"); - $facility = $facmap{$facility} if ( $facmap{$facility} ); - $loglevel = '*' if ( $loglevel eq 'all' ); - - $entries{$target} = {} unless $entries{$target}; - add_target_selector( $facility . '.' . $loglevel, $target ); - } - - # This is a file target so we set size and files - if ($target =~ m:^/var/log/:) { - set_target_param($config, $level, $target, 'size'); - set_target_param($config, $level, $target, 'files'); - } -} - -sub print_outchannel { - my ( $fh, $channel, $target, $size ) = @_; - # Force outchannel size to be 1k more than logrotate config to guarantee rotation - $size = ($size + 5) * 1024; - print $fh "\$outchannel $channel,$target,$size,/usr/sbin/logrotate ${LOGROTATE_CFG_DIR}/$channel\n"; - print $fh join( ';', @{ $entries{$target}{selector} } ), " :omfile:\$$channel\n"; -} - -my $config = new Vyatta::Config; -$config->setLevel("system syslog"); - -read_config( $config, 'global', $MESSAGES ); - -# Default syslog.conf if no global entry -unless (%entries) { - add_target_selector( '*.notice', $MESSAGES ); - add_target_selector( 'local7.*', $MESSAGES ); -} - -read_config( $config, 'console', $CONSOLE ); - -foreach my $host ( $config->listNodes('host') ) { - my $host_protocol; - foreach my $facility ( $config->listNodes("host $host facility") ) { - my $protocol = $config->returnValue("host $host facility $facility protocol"); - if ($protocol eq "tcp") { - $host_protocol = "@@"; - } else { - $host_protocol = "@"; - } - read_config( $config, "host $host", $host_protocol. $host ); - } -} - -foreach my $file ( $config->listNodes('file') ) { - read_config( $config, "file $file", '/var/log/user/' . $file ); -} - -foreach my $user ( $config->listNodes('user') ) { - read_config( $config, 'user $user', $user ); -} - -my ($out, $tempname) = tempfile($SYSLOG_TMPL, UNLINK => 1) - or die "Can't create temp file: $!"; - -my $files; -my $size; -foreach my $target ( keys %entries ) { - if ($target eq $MESSAGES) { - $size = get_target_param($target, 'size'); - $files = get_target_param($target, 'files'); - print_outchannel($out, 'global', $target, $size); - system("sudo /opt/vyatta/sbin/vyatta_update_logrotate.pl $files $size 1") == 0 - or die "Can't genrate global log rotation config: $!"; - } elsif ($target =~ m:^/var/log/user/:) { - my $file = basename($target); - $size = get_target_param($target, 'size'); - $files = get_target_param($target, 'files'); - print_outchannel($out, 'file_' . $file, $target, $size); - system("sudo /opt/vyatta/sbin/vyatta_update_logrotate.pl $file $files $size 1") == 0 - or die "Can't genrate global log rotation config: $!"; - } else { - print $out join( ';', @{ $entries{$target}{selector} } ), "\t$target\n"; - } -} -close $out - or die "Can't output $tempname: $!"; - -# Don't need to do anything, save time on boot -if ( -e $SYSLOG_CONF && compare( $SYSLOG_CONF, $tempname ) == 0 ) { - unlink($tempname); - exit 1; -} - -system("sudo cp $tempname $SYSLOG_CONF") == 0 - or die "Can't copy $tempname to $SYSLOG_CONF: $!"; - -unlink($tempname); -exit 0; diff --git a/scripts/telnetd.init b/scripts/telnetd.init deleted file mode 100755 index fdb63040..00000000 --- a/scripts/telnetd.init +++ /dev/null @@ -1,90 +0,0 @@ -#! /bin/bash - -### BEGIN INIT INFO -# Provides: telnetd -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: -# Default-Stop: -# Short-Description: Busybox telnet daemon -### END INIT INFO - -declare progname=${0##*/} -declare action=$1; shift - -port=$1; shift -addr=$1; shift - -: ${port:=23} -: ${bb:=/bin/busybox} - -test -x $bb || exit 0 - -running_pid () -{ - pidof $bb | while read pid ; do - f=$(tr '\000' '\t' < /proc/$pid/cmdline 2>/dev/null | cut -f2) - if [ "$f" == telnetd ] ; then - echo $pid - return - fi - done - false -} - -start_telnetd () -{ - if [ -n "$addr" ] - then $bb telnetd -p $port -b $addr - else $bb telnetd -p $port - fi -} - - -start () -{ - local -i pid=$( running_pid ) - - [ $pid -ne 0 ] && return - start_telnetd -} - -stop () -{ - local -i pid=$( running_pid ) - if [ $pid -ne 0 ] - then kill $pid - else return 0 - fi -} - -restart() -{ - local -i pid=$( running_pid ) - if [ $pid -ne 0 ] - then kill $pid - sleep 1 - fi - start_telnetd -} - -status () -{ - local -i pid=$( running_pid ) - if [ $pid -ne 0 ] - then echo running - return - else - echo not running - false - fi -} - -case "$action" in - start) start;; - stop) stop;; - restart) restart;; - status) status;; - *) echo "Usage: $progname {start|stop|restart|status}" - exit 1 -esac diff --git a/scripts/vyatta-bridgegroup-depedency.pl b/scripts/vyatta-bridgegroup-depedency.pl deleted file mode 100755 index 03d92ed0..00000000 --- a/scripts/vyatta-bridgegroup-depedency.pl +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-bridgegroup-dependency.pl -# -# **** 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) 2010 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: February 2010 -# Description: To check dependency between bridge and interfaces assigned to it -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Vyatta::Config; -use Vyatta::Misc; -use Getopt::Long; -use POSIX; - -use strict; -use warnings; - -sub check_bridge_interfaces { - my $bridge_intf = shift; - foreach my $name ( Vyatta::Misc::getInterfaces() ) { - my $intf = new Vyatta::Interface($name); - next unless $intf; - my $intf_bridge = undef; - $intf_bridge = $intf->bridge_grp(); - if (defined $intf_bridge && $intf_bridge eq $bridge_intf) { - return "Interfaces are still assigned to bridge $bridge_intf"; - } - } - return; -} - -sub is_bridge_deleted { - my $bridge_name = shift; - my $config = new Vyatta::Config; - my @bridge_intfs = $config->listNodes("interfaces bridge"); - my @orig_bridge_intfs = $config->listOrigNodes("interfaces bridge"); - if (scalar(grep(/^$bridge_name$/, @bridge_intfs)) == 0) { - if (scalar(grep(/^$bridge_name$/, @orig_bridge_intfs)) > 0) { - # bridge deleted in proposed config - return; - } - } - exit 1; -} - -# -# main -# - -my ($error, $warning); -my ($no_interfaces_assigned, $bridge_interface, $bridge_notin_proposedcfg); - -GetOptions( "no-interfaces-assigned!" => \$no_interfaces_assigned, - "bridge-interface=s" => \$bridge_interface, - "bridge-notin-proposedcfg!" => \$bridge_notin_proposedcfg); - -die "undefined bridge interface" if ! defined $bridge_interface; - -($error, $warning) = check_bridge_interfaces($bridge_interface) - if ($no_interfaces_assigned); - -($error, $warning) = is_bridge_deleted($bridge_interface) - if ($bridge_notin_proposedcfg); - -if (defined $warning) { - print "$warning\n"; -} - -if (defined $error) { - print "$error\n"; - exit 1; -} - -exit 0; diff --git a/scripts/vyatta-functions b/scripts/vyatta-functions deleted file mode 100755 index f3263f13..00000000 --- a/scripts/vyatta-functions +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# Module: vyatta-functions -# -# **** 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) 2006, 2007 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Tom Grennan -# Date: 2006 -# Description: -# -# **** End License **** -# -# - -trap 'progress_indicator "stop"; echo; exit 1' 1 -trap 'progress_indicator "stop"; echo; exit 1' 2 - -# progress indicator for long running programs -progress_indicator () { - case "$1" in - "start") /usr/bin/progress-indicator $2& - ;; - "stop") rm -f /tmp/pi.$2 - sleep 2 - echo -n -e "\b" - ;; - esac -} - diff --git a/scripts/vyatta-update-grub.pl b/scripts/vyatta-update-grub.pl deleted file mode 100755 index e4110ee0..00000000 --- a/scripts/vyatta-update-grub.pl +++ /dev/null @@ -1,278 +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) 2010 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Bob Gilligan -# Date: Jully, 2010 -# Description: Script to update the grub config file after full upgrade. -# -# **** End License **** - -use strict; -use warnings; -use Getopt::Long; -use File::Temp qw/ :mktemp /; - -my $UNION_BOOT_DIR = `/opt/vyatta/sbin/vyos-persistpath` . '/boot'; -my $UNION_GRUB_CFG_DIR = "$UNION_BOOT_DIR/grub"; -my $DISK_BOOT_DIR = '/boot'; -my $DISK_GRUB_CFG_DIR= '/boot/grub'; -my $OLD_IMG_VER_STR = 'Old-non-image-installation'; - -# Returns the version string of the currently running system. -# The logic is roughly like this: -# -# First, figure out whether system is image-booted or standard booted. -# Next, locate the grub config file. -# Next, edit all entries for running image to use the vmlinuz and -# initrd.img symlinks instead of specific kernel and initrd files. -# Next, change the vmlinuz and initrd.img symlinks to point to the -# correct kernel and initrd.img files. -# -sub curVer { - my $vers = `awk '{print \$1}' /proc/cmdline`; - - # In an image-booted system, the image name is the directory name - # directory under "/boot" in the pathname of the kernel we booted. - $vers =~ s/BOOT_IMAGE=\/boot\///; - $vers =~ s/\/?vmlinuz.*\n$//; - - # In a non-image system, the kernel resides directly under "/boot". - # No second-level directory means that $vers will be null. - if ($vers eq "") { - $vers = $OLD_IMG_VER_STR; - } - return $vers; -} - -my $boot_dir; -my $grub_cfg_dir; -my $grub_cfg_file; -my $tmp_grub_cfg_file; -my $on_disk_kernel_dir; -my $local_kernel_dir; -my $running_image_name; -my $debug_flag = 0; - -GetOptions( - "debug" => \$debug_flag, - ); - - -sub log_msg { - my $message = shift; - - print "DEBUG: $message" if $debug_flag; -} - - -# Main - -if (-e $UNION_BOOT_DIR) { - $boot_dir = $UNION_BOOT_DIR; - $grub_cfg_dir = $UNION_GRUB_CFG_DIR; - - $running_image_name = curVer(); - if ($running_image_name eq $OLD_IMG_VER_STR) { - print "Can't find image name for union booted system.\n"; - exit 1; - } - $on_disk_kernel_dir = "/boot/$running_image_name"; - $local_kernel_dir = "$boot_dir/$running_image_name"; - if (! -e $local_kernel_dir) { - print "Can't find kernel directory: $local_kernel_dir\n"; - exit 1; - } - log_msg("System is image booted.\n"); -} elsif (-e $DISK_BOOT_DIR) { - $boot_dir = $DISK_BOOT_DIR; - $grub_cfg_dir = $DISK_GRUB_CFG_DIR; - $on_disk_kernel_dir = $boot_dir; - $local_kernel_dir = $boot_dir; - $running_image_name = ""; - log_msg("System is disk booted.\n"); -} else { - print "Can't locate boot directory!\n"; - exit 1; -} - -$grub_cfg_file = "$grub_cfg_dir/grub.cfg"; - -if (! -e $grub_cfg_file) { - print "can't locate grub config file: $grub_cfg_file\n"; - exit 1; -} - -if (-e "$local_kernel_dir/linux" && ! -l "$local_kernel_dir/linux") { - print "Linux binary is not a symlink: $local_kernel_dir/linux\n"; - exit 1; -} - -if (-e "$local_kernel_dir/initrd.img" && ! -l "$local_kernel_dir/initrd.img") { - print "initrd file is not a symlink: $local_kernel_dir/initrd.img\n"; - exit 1; -} - -# Back up the original grub config file -system("cp $grub_cfg_file $grub_cfg_dir/orig_grub.cfg"); -if ($? >> 8) { - print "Couldn't back up original grub config file.\n"; - exit 1; -} - -# Make temp copy to work on -$tmp_grub_cfg_file = $grub_cfg_file . ".tmp"; - -system("cp $grub_cfg_file $tmp_grub_cfg_file"); -if ($? >> 8) { - print "Couldn't back up temp copy of grub config file.\n"; - exit 1; -} - -my $sedcmd="sed -i 's+linux $on_disk_kernel_dir\/vmlinuz-[^ ]* +linux $on_disk_kernel_dir\/vmlinuz +' $tmp_grub_cfg_file"; - -log_msg("Executing: $sedcmd \n"); - -system($sedcmd); -if ($? >> 8) { - print "Couldn't edit linux entry in grub config file: $tmp_grub_cfg_file"; - exit 1; -} - - -$sedcmd="sed -i 's+initrd $on_disk_kernel_dir\/initrd.img-[^ ]*\$+initrd $on_disk_kernel_dir\/initrd.img +' $tmp_grub_cfg_file"; - -log_msg("Executing: $sedcmd \n"); - -system($sedcmd); -if ($? >> 8) { - print "Couldn't edit initrd entry in grub config file: $tmp_grub_cfg_file"; - exit 1; -} - -my $kern_vers=`ls $local_kernel_dir/vmlinuz-*`; - -my @kern_vers_list = split(' ', $kern_vers); - -if ($#kern_vers_list < 0) { - print "No kernel binary files found in grub boot dir: $local_kernel_dir\n"; - exit 1; -} - -log_msg("kern_vers_list before subst is: @kern_vers_list\n"); - -foreach (@kern_vers_list) { - s/$local_kernel_dir\/vmlinuz-//; -} - -log_msg("kern_vers_list after subst is: @kern_vers_list\n"); - -# -# Sort in reverse lexacographic order (highest version number first), and -# then sort all images that match the type of kerenl we are -# running (virt or non-virt) ahead of those that do not. - -@kern_vers_list = sort(@kern_vers_list); - -log_msg("kern_vers_list after sort is: @kern_vers_list\n"); - -my @p1; -my @p2; - -my $running_kern = `uname -r`; - -my $index; -for ($index = $#kern_vers_list; $index >= 0; $index--) { - my $kv = $kern_vers_list[$index]; - if ($running_kern =~ /virt/) { - if ($kv =~ /virt/) { - push @p1, $kv; - } else { - push @p2, $kv; - } - } else { - if ($kv !~ /virt/) { - push @p1, $kv; - } else { - push @p2, $kv; - } - } -} - -log_msg("p1 is: @p1\n"); -log_msg("p2 is: @p2\n"); - -@kern_vers_list = @p1; -push(@kern_vers_list, @p2); - -log_msg("kern_vers_list after subst and sort is: @kern_vers_list\n"); - - -# Search sorted list to find first version that has both a kernel and -# an initrd file, then make the symlinks point to those files. -foreach my $vers (@kern_vers_list) { - if (-e "$local_kernel_dir/vmlinuz-$vers" && - -e "$local_kernel_dir/initrd.img-$vers") { - log_msg("Using version $vers\n"); - - # Up to this point, this script has done nothing destructive. Any - # failures in which the script exited will leave grub directory and - # config file un-modified. Failures after this point could leave - # grub directory or config file in an inconsistent state, leaving - # the system un-bootable. - - system("rm -f $local_kernel_dir/vmlinuz"); - if ($? >> 8) { - print "Couldn't remove kernel symlink: $local_kernel_dir/vmlinuz-$vers\n"; - # If symlink actually wasn't removed, grub dir will remain - # in previous state. - exit 1; - } - - system("ln -s vmlinuz-$vers $local_kernel_dir/vmlinuz"); - if ($? >> 8) { - print "Couldn't symlink kernel binary: $local_kernel_dir/vmlinuz-$vers\n"; - exit 1; - } - - system("rm -f $local_kernel_dir/initrd.img"); - if ($? >> 8) { - print "Couldn't remove initrd symlink: $local_kernel_dir/initrd-$vers\n"; - exit 1; - } - - system("ln -s initrd.img-$vers $local_kernel_dir/initrd.img"); - if ($? >> 8) { - print "Couldn't symlink initrd file: $local_kernel_dir/initrd.img-$vers\n"; - exit 1; - } - - # As final step, move our edited grub config file back into position - system("mv $tmp_grub_cfg_file $grub_cfg_file"); - if ($? >> 8) { - print "Couldn't move edited grub config file into position: $grub_cfg_file\n"; - exit 1; - } - - system("rm -f $tmp_grub_cfg_file"); - - # Success! - print "Done.\n"; - exit 0; - } -} - -print "Couldn't find matching vmlinuz and initrd.img files!\n"; -exit 1; diff --git a/scripts/vyos-popcon.pl b/scripts/vyos-popcon.pl deleted file mode 100644 index eb27749f..00000000 --- a/scripts/vyos-popcon.pl +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/env perl -# -# Module: vyos-popcon.pl -# Sends anonymous system information to a server -# -# Copyright (C) 2015 VyOS maintainers and contributors -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -use lib "/opt/vyatta/share/perl5/"; - -use strict; -use warnings; -use File::Slurp; -use JSON::Any; -use LWP::UserAgent; -use Vyatta::Config; - -use Data::Dumper; - -my %data = (); -my $config = new Vyatta::Config(); -my $json = new JSON::Any(); - -my $uuid_file = "/config/auth/popcon.uuid"; -my $version_file = "/opt/vyatta/etc/version"; - -my $url = "http://popcon.vyos.net/submit"; - -sub send_to { - my $data = shift; - - my $ua = LWP::UserAgent->new; - $ua->agent("VyOS/popcon"); - - my $req = HTTP::Request->new(POST => $url); - $req->content_type('application/json'); - $req->content($data); - - my $res = $ua->request($req); - - if ($res->is_success) { - print $res->content; - } - else { - print $res->status_line, "\n"; - } -} - -sub get_system_id -{ - my $uuid = read_file($uuid_file); - $uuid =~ s/(.*)\s/$1/; - return $uuid; -} - -sub get_version -{ - my $contents = read_file($version_file); - my ($version) = $contents =~ /Version\:\s*VyOS\s+(.*)\s/; - return $version; -} - -sub get_arch -{ - my $arch = `uname -m`; - $arch =~ s/(.*)\s/$1/; - return $arch; -} - -sub get_cpus -{ - my $output = `lscpu`; - my ($cpus) = $output =~ /CPU\(s\)\:\s+(.*)\s/; - return $cpus; -} - -sub get_ram -{ - my $output = read_file('/proc/meminfo'); - my ($ram) = $output =~ /MemTotal:\s+(\d+)\s/; - $ram = int($ram / 1024); # megabytes - return $ram; -} - -sub get_features -{ - my @features = (); - push(@features, "bgp") if $config->exists("protocols bgp"); - push(@features, "ospf") if $config->exists("protocols ospf"); - push(@features, "ospfv3") if $config->exists("protocols ospfv3"); - push(@features, "rip") if $config->exists("protocols rip"); - push(@features, "ripng") if $config->exists("protocols ripng"); - push(@features, "nat") if $config->exists("nat"); - push(@features, "webproxy") if $config->exists("service webproxy"); - push(@features, "url-filtering") if $config->exists("service webproxy url-filtering"); - push(@features, "dns-forwarding") if $config->exists("service dns forwarding"); - push(@features, "dhcp-server") if $config->exists("service dhcp-server"); - push(@features, "dhcp-relay") if $config->exists("service dhcp-relay"); - push(@features, "dhcpv6-server") if $config->exists("service dhcpv6-server"); - push(@features, "dhcpv6-relay") if $config->exists("service dhcpv6-relay"); - push(@features, "netflow") if $config->exists("system flow-accounting netflow"); - push(@features, "sflow") if $config->exists("system flow-accounting sflow"); - push(@features, "snmp") if $config->exists("service snmp"); - push(@features, "lldp") if $config->exists("service lldp"); - push(@features, "telnet") if $config->exists("service telnet"); - push(@features, "pppoe-server") if $config->exists("service pppoe-server"); - push(@features, "ipsec") if $config->exists("vpn ipsec site-to-site"); - push(@features, "dmvpn") if ($config->exists("vpn ipsec profile") && $config->exists("protocols nhrp")); - push(@features, "l2tp") if $config->exists("vpn l2tp remote-access"); - push(@features, "pptp") if $config->exists("vpn pptp remote-access"); - push(@features, "l2tpv3") if $config->exists("interfaces l2tpv3"); - push(@features, "openvpn") if $config->exists("interfaces openvpn"); - push(@features, "vxlan") if $config->exists("interfaces vxlan"); - push(@features, "vti") if $config->exists("interfaces vti"); - push(@features, "qos") if $config->exists("traffic-policy"); - push(@features, "bonding") if $config->exists("interfaces bonding"); - push(@features, "bridge") if $config->exists("interfaces bridge"); - push(@features, "tunnel") if $config->exists("interfaces tunnel"); - push(@features, "cluster") if $config->exists("cluster"); - push(@features, "load-balancing") if $config->exists("load-balancing wan"); - push(@features, "firewall") if $config->exists("firewall name"); - push(@features, "ipv6-firewall") if $config->exists("firewall ipv6-name"); - push(@features, "zone") if $config->exists("zone-policy"); - - return (join ",", @features); -} - -if (! -f $uuid_file) -{ - # Generate the UUID file if it's missing - system("uuid > $uuid_file"); -} - -# Prepare the data -$data{"uuid"} = get_system_id(); -$data{"version"} = get_version(); -$data{"arch"} = get_arch(); -$data{"cpus"} = get_cpus(); -$data{"ram"} = get_ram(); -$data{"features"} = get_features(); - -send_to($json->objToJson(\%data)); - diff --git a/tests/interface.pl b/tests/interface.pl deleted file mode 100644 index 9ebeb60b..00000000 --- a/tests/interface.pl +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/perl - -# Standalone test for Vyatta::Interface, not intended to be used -# directly - - -use strict; -use warnings; -use Vyatta::Interface; -use Vyatta::Misc; - -my @interfaces = getInterfaces(); -print "Interfaces: ", join(' ',@interfaces),"\n"; - -print "IP\n"; -foreach my $type (qw/all broadcast multicast pointtopoint loopback/) { - print "\t$type = "; - foreach my $addr (Vyatta::Misc::getInterfacesIPadresses($type)) { - print $addr, '(', is_ip_v4_or_v6($addr), ') '; - } - print "\n"; -} - - -foreach my $arg (@interfaces) { - print "$arg : "; - my $intf = new Vyatta::Interface($arg); - - if (! $intf) { - print "undefined\n"; - next; - } - - my $vif = $intf->vif(); - print "vif=$vif " if $vif; - printf "path = '%s'\ndevice=%s\n", $intf->path(), $intf->physicalDevice(); - - my @addresses = $intf->address(); - if ($#addresses eq -1) { - print "address is no set\n"; - } else { - print "address ", join(' ',@addresses), "\n"; - } - - foreach my $attr (qw(exists configured disabled using_dhcp flags up running)) { - my $val = $intf->$attr(); - print " $attr=$val" if ($val); - } - print "\n"; -} - -exit 0; diff --git a/tests/isip.pl b/tests/isip.pl deleted file mode 100644 index 35a04b7a..00000000 --- a/tests/isip.pl +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/perl - -# Standalone test for Vyatta::Misc::isIPInterfaces - -use strict; -use warnings; -use Vyatta::Misc; -use Vyatta::Interface; - -my $vc; -my @interfaces = getInterfaces(); -print "Interfaces: ", join(' ',@interfaces),"\n"; - -foreach my $lip (@ARGV) { - print $lip, " is"; - if (Vyatta::Misc::isIPinInterfaces($vc, $lip, @interfaces)) { - print " in\n"; - } else { - print " not in\n"; - } -} - -exit 0; |