summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_file_in_config_dir32
-rwxr-xr-xscripts/install/install-functions24
-rwxr-xr-xscripts/install/install-get-partition22
-rwxr-xr-xscripts/install/install-image-existing14
-rwxr-xr-xscripts/install/install-postinst-new2
-rwxr-xr-xscripts/standalone_root_pw_reset2
-rw-r--r--scripts/system/vyatta_check_domainname.pl72
-rw-r--r--scripts/system/vyatta_update_sysctl.pl87
-rwxr-xr-xscripts/vyatta-address69
-rw-r--r--scripts/vyatta-dhcp-helper.pl62
-rwxr-xr-xscripts/vyatta-grub-setup227
-rwxr-xr-xscripts/vyatta-raid-event113
-rwxr-xr-xscripts/vyatta-tunnel-cleanup30
-rw-r--r--scripts/vyatta-tunnel-dhcp.pl28
-rw-r--r--scripts/vyatta-update-tunnel.pl27
15 files changed, 168 insertions, 643 deletions
diff --git a/scripts/check_file_in_config_dir b/scripts/check_file_in_config_dir
deleted file mode 100644
index bceb2858..00000000
--- a/scripts/check_file_in_config_dir
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-# **** 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) 2011 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Mohit Mehta <mohit@vyatta.com>
-# Description: Check if the given file is under /config. Used for files that
-# are referenced from the CLI and need to be preserved during
-# image upgrade. Warn the user if these aren't under /config
-#
-# **** End License ****
-
-FILE=$1
-CONFIG_DIR=$2
-
-if [[ ( $FILE =~ ^\/config\/.*$ ) || \
- ( $FILE =~ ^\/opt\/vyatta\/etc\/config\/.*$ ) ]]; then
- exit 0
-else
- echo Warning: \'$FILE\' lies outside of $CONFIG_DIR directory. \
- It will not get preserved during image upgrade.
-fi
diff --git a/scripts/install/install-functions b/scripts/install/install-functions
index b3ec42c1..feeeb489 100755
--- a/scripts/install/install-functions
+++ b/scripts/install/install-functions
@@ -86,10 +86,10 @@ tolower () {
}
# Validates a user response. Returns the response if valid.
-# Returns the default is the user just hits enter.
+# Returns the default is the user just hits enter.
# Returns nothing if not valid. Default parameter is $1.
# Options are in $2. If options are defined return must be a member
-# of the enum.
+# of the enum.
get_response () {
local ldefault=$(tolower "$1")
local loptions=$(tolower "$2")
@@ -370,6 +370,26 @@ EOF
return 1
}
+# try to unmount. log any errors and return the appropriate status.
+# $1: arguments for umount
+try_unmount ()
+{
+ args="$*"
+ output=$(eval "umount $args 2>&1")
+ status=$?
+ if [ $status == 0 ]; then
+ return 0
+ fi
+ # error
+ cat <<EOF
+Error trying to unmount a partition/directory.
+Please see $INSTALL_LOG for details.
+EOF
+ lecho 'Error trying to unmount a partition/directory.'
+ lecho "umount $args\n$output"
+ return 1
+}
+
# Find 2 drives of the same size.
get_size_raid ()
{
diff --git a/scripts/install/install-get-partition b/scripts/install/install-get-partition
index 138088e6..bb8d8c11 100755
--- a/scripts/install/install-get-partition
+++ b/scripts/install/install-get-partition
@@ -100,8 +100,10 @@ check_for_new_raid () {
driveName=()
driveSize=()
driveNameSize=()
- drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \
- | egrep -v "[0-9]$" | egrep -v "^$")
+ drives=$(cat /proc/partitions | \
+ awk '{ if ($4!="name") { print $4 } }' | \
+ egrep "c[0-9]d[0-9]$|[hsv]d[a-z]$|nvme[0-9]n[0-9]$|mmcblk[0-9]" | \
+ egrep -v "^$" | sort)
for instdrv in $drives
do
@@ -235,9 +237,9 @@ check_for_new_raid () {
if [ -d /sys/firmware/efi ]; then
#EFI moves the data parition on RAID to 3
data_dev=3
- echo "Create data partition: /dev/${drive}${data_dev}"
+ echo "Create data partition: ${data_dev} on /dev/${drive}"
else
- echo "Creating data partition: /dev/${drive}${data_dev}"
+ echo "Creating data partition: ${data_dev} on /dev/${drive}"
sfdisk --part-type /dev/$drive $data_dev 0xfd >/dev/null 2>&1
# mark data partition as bootable
lecho "Marking /dev/$drive partition $data_dev bootable"
@@ -251,15 +253,19 @@ check_for_new_raid () {
echo
for drive in $drives; do
- echo "Erasing any previous RAID metadata that may exist on /dev/${drive}${data_dev}"
- mdadm --zero-superblock /dev/${drive}${data_dev}
+ # add "p" suffix for partitions on storages like eMMC, NVME
+ if [[ -n $(echo ${drive} | egrep "c[0-9]d[0-9]$|nvme[0-9]n[0-9]$|mmcblk[0-9]") ]]; then
+ partprefix="p"
+ fi
+ echo "Erasing any previous RAID metadata that may exist on /dev/${drive}${partprefix}${data_dev}"
+ mdadm --zero-superblock /dev/${drive}${partprefix}${data_dev}
done
- echo "Creating RAID-1 group on partitions: /dev/${drive1}${data_dev} /dev/${drive2}${data_dev}"
+ echo "Creating RAID-1 group on partitions: /dev/${drive1}${partprefix}${data_dev} /dev/${drive2}${partprefix}${data_dev}"
raid_dev=md0
yes|mdadm --create /dev/$raid_dev --level=1 --raid-disks=2 --metadata=0.90 \
- /dev/${drive1}${data_dev} /dev/${drive2}${data_dev}
+ /dev/${drive1}${partprefix}${data_dev} /dev/${drive2}${partprefix}${data_dev}
if [ $? = 0 -a -e /dev/$raid_dev ]; then
echo "RAID-1 group created successfully:"
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index d00d7735..7cf0b4db 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -189,9 +189,9 @@ if [ $space_avail -gt $space_needed_configdata ]; then
resp=$(get_response "Yes" "Yes No Y N")
if [ "$resp" == 'yes' ] || [ "$resp" == 'y' ]; then
echo 'Copying current configuration...'
- ndir=${INST_ROOT}/${VYATTA_NEW_CFG_DIR}
+ ndir=${INST_ROOT}/${VYATTA_CFG_DIR}
mkdir -p $ndir
- find $VYATTA_NEW_CFG_DIR -maxdepth 1 -mindepth 1 \
+ find $VYATTA_CFG_DIR -maxdepth 1 -mindepth 1 \
-exec cp '-a' '{}' "$ndir/" ';'
# Set the upgraded flag
@@ -201,7 +201,7 @@ if [ $space_avail -gt $space_needed_configdata ]; then
chmod -R 775 $ndir
# Return original permissions for private files in config/auth. T2713
- rsync -a ${VYATTA_NEW_CFG_DIR}/auth/ ${ndir}/auth/
+ rsync -a ${VYATTA_CFG_DIR}/auth/ ${ndir}/auth/
fi
done
@@ -278,6 +278,14 @@ if [ -e "$DEF_GRUB" ]; then
fi
fi
+# unmount filesystems
+if ! try_unmount "--read-only $INST_ROOT $READ_ROOT"; then
+ failure_exit 'Failed to unmount new squashfs image.'
+fi
+
+# sync underlaying filesystems
+sync
+
logger -p local3.warning -t "SystemImage" "System Image $NEWNAME has been added and made the default boot image"
echo 'Done.'
diff --git a/scripts/install/install-postinst-new b/scripts/install/install-postinst-new
index 8bb7c8bd..14148045 100755
--- a/scripts/install/install-postinst-new
+++ b/scripts/install/install-postinst-new
@@ -157,7 +157,7 @@ install_grub () {
else
if [[ $grub_inst_drv == "md raid" ]]; then
for slave in $raid_slaves; do
- grub_inst_drv=${slave:0:3}
+ grub_inst_drv=$(lsblk --noempty --dedup PKNAME --nodeps --noheadings --output PKNAME /dev/${slave})
output=$(grub-install --no-floppy --recheck --root-directory=$grub_root \
/dev/$grub_inst_drv 2>&1)
lecho "$output"
diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset
index 1a73de71..c82cea32 100755
--- a/scripts/standalone_root_pw_reset
+++ b/scripts/standalone_root_pw_reset
@@ -28,7 +28,7 @@ ADMIN=vyos
set_encrypted_password() {
sed -i \
- -e "/ user $1 {/,/}/s/encrypted-password .*\$/encrypted-password $2/" $3
+ -e "/ user $1 {/,/encrypted-password/s/encrypted-password .*\$/encrypted-password \"$2\"/" $3
}
diff --git a/scripts/system/vyatta_check_domainname.pl b/scripts/system/vyatta_check_domainname.pl
deleted file mode 100644
index a6e0d227..00000000
--- a/scripts/system/vyatta_check_domainname.pl
+++ /dev/null
@@ -1,72 +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;
-
-# Source: http://en.wikipedia.org/wiki/Domain_Name_System
-# Rules for forming domain names appear in RFC 1035, RFC 1123, and RFC 2181.
-# A domain name consists of one or more parts, technically called labels,
-# that are conventionally concatenated, and delimited by dots,
-# such as example.com.
-#
-# * The right-most label conveys the top-level domain; for example,
-# the domain name www.example.com belongs to the top-level domain com.
-# * The hierarchy of domains descends from right to left; each label to
-# the left specifies a subdivision, or subdomain of the domain to the
-# right. For example: the label example specifies a subdomain of the
-# com domain, and www is a sub domain of example.com. This tree of
-# subdivisions may have up to 127 levels.
-#
-# * Each label may contain up to 63 characters. The full domain name may
-# not exceed a total length of 253 characters in its external
-# dotted-label specification.[10] In the internal binary
-# representation of the DNS the maximum length requires 255 octets of
-# storage.[3] In practice, some domain registries may have shorter
-# limits.[citation needed]
-#
-# * DNS names may technically consist of any character representable in
-# an octet. However, the allowed formulation of domain names in the
-# DNS root zone, and most other sub domains, uses a preferred format
-# and character set. The characters allowed in a label are a subset
-# of the ASCII character set, and includes the characters a through
-# z, A through Z, digits 0 through 9, and the hyphen. This rule is
-# known as the LDH rule (letters, digits, hyphen). Domain names are
-# interpreted in case-independent manner. Labels may not start or end
-# with a hyphen.[11]
-
-foreach my $fqdn (@ARGV) {
- die "$fqdn: full domain length exceeds 253 characters\n"
- if length($fqdn) > 253;
-
- my @label = split /\./, $fqdn;
- die "$fqdn: domain name greater than 127 levels\n"
- if ($#label > 127);
-
- foreach my $label (@label) {
- die "$label: invalid character in domain name\n"
- unless $label =~ /^[-0-9a-zA-Z]+$/;
-
- die "$label: label must not start or end with hyphen\n"
- if $label =~ /(^-)|(-$)/;
-
- die "$label: domain name element greater than 63 characters\n"
- if (length($label) > 63);
- }
-}
-
diff --git a/scripts/system/vyatta_update_sysctl.pl b/scripts/system/vyatta_update_sysctl.pl
deleted file mode 100644
index adc84178..00000000
--- a/scripts/system/vyatta_update_sysctl.pl
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/perl
-#
-# Module: vyatta_update_sysctl.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.
-#
-# 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) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Jason Hendry
-# Date: October 2014
-# Description: Script to manage sysctl values
-#
-# **** End License ****
-#
-
-use lib "/opt/vyatta/share/perl5/";
-use Vyatta::Config;
-use Vyatta::File qw(touch);
-
-use Getopt::Long;
-
-use strict;
-use warnings;
-
-my $SYSCTL = '/sbin/sysctl';
-
-my (@opts);
-
-sub usage {
- print <<EOF;
-Usage: $0 --option=<sysctl_option> <value>
-EOF
- exit 1;
-}
-
-GetOptions(
- "option=s{2,}" => \@opts,
- ) or usage();
-
-set_sysctl_value(@opts) if (@opts);
-exit 0;
-
-sub set_sysctl_value {
- my ($sysctl_opt, @nvaluearr) = @_;
- my $nvalue = join ' ',@nvaluearr;
- my $ovalue = get_sysctl_value($sysctl_opt);
-
- if ($nvalue ne $ovalue) {
- my $cmd = "$SYSCTL -w $sysctl_opt=\"$nvalue\" 2>&1> /dev/null";
- system($cmd);
- if ($? >> 8) {
- die "exec of $SYSCTL failed: '$cmd'";
- }
- }
-}
-
-sub get_sysctl_value {
- my $option = shift;
- my $val;
-
- open( my $sysctl, '-|', "$SYSCTL $option 2>&1" ) or die "sysctl failed: $!\n";
- while (<$sysctl>) {
- chomp;
- $val = (split(/ = /, $_))[1];
- }
- close $sysctl;
- return ($val);
-}
-
-# net.ipv4.ipfrag_time
diff --git a/scripts/vyatta-address b/scripts/vyatta-address
deleted file mode 100755
index ed9a298e..00000000
--- a/scripts/vyatta-address
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /bin/bash
-#
-# Wrapper around ip link command that handles IPv4, IPv6 and DHCP
-# This is done in shell rather than perl to avoid the overhead of recompilation
-
-if [ $# -ne 3 ]; then
- echo "Usage: $0 {add|delete} interface address"
- exit 1
-fi
-
-case $1 in
- add)
- if [[ "$3" = "dhcp" ]]; then
- exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=start
- elif [[ "$3" = "dhcpv6" ]]; then
- exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --start -ifname "$2"
- elif [[ "$3" =~ ":" ]]; then
- # Ipv6 address
- if ! ip -6 addr list dev $2 | grep -q $3; then
- exec sudo ip -6 addr add "$3" dev "$2"
- fi
- else
- if ! ip addr list dev $2 | grep -q $3; then
- exec sudo ip addr add "$3" broadcast + dev "$2"
- fi
- fi ;;
-
- delete)
- # Get current address from interface when using DHCP
- if [[ "$3" = "dhcp" ]]; then
- lease_file=/var/lib/dhcp/dhclient_"$(echo $2 | sed -e 's/\./_/')".leases;
- ip=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p');
- #ip_address=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p');
- # T1053 we need IP/prefix for normalize-ip to function
- ip_address=$(ip a s dev $2 | grep "inet $ip" | awk '{print $2}')
- elif [[ "$3" = "dhcpv6" ]]; then
- lease_file=/var/lib/dhcp/dhclient_v6_"$(echo $2 | sed -e 's/\./_/')".leases;
- ip_address=$(sed -n 's/^\s\s\s\siaaddr\s\(.*\)\s{/\1/p' $lease_file | sed -n '$p');
- else
- ip_address=$3;
- fi
- if [[ "$ip_address" = "" ]]; then
- ip_address='0.0.0.0/0'
- fi
-
- ### T1053 parameter $ip_address needs to be prefixed, not just the IP
- ip_address=$(/usr/libexec/vyos/system/normalize-ip $ip_address)
-
- if ! ip address show dev $2 2>/dev/null | grep -q "$ip_address"; then
- # Address doesn't exist there, nothing to delete
- exit 0
- fi
-
- if [ ! -d "/sys/class/net/$2" ]; then
- # device is already gone
- exit 0
- elif [[ "$3" = "dhcp" ]]; then
- exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=stop
- elif [[ "$3" = "dhcpv6" ]]; then
- exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --ifname "$2"
- elif [[ "$3" =~ ":" ]]; then
- exec sudo ip -6 addr del "$ip_address" dev "$2"
- else
- exec sudo ip addr del "$ip_address" dev "$2"
- fi ;;
- *)
- echo "Unknown option $1"
- exit 1 ;;
-esac
diff --git a/scripts/vyatta-dhcp-helper.pl b/scripts/vyatta-dhcp-helper.pl
deleted file mode 100644
index 1001430e..00000000
--- a/scripts/vyatta-dhcp-helper.pl
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Long;
-use strict;
-use lib "/opt/vyatta/share/perl5";
-use Vyatta::Misc;
-
-my ($iface, $want);
-GetOptions("interface=s" => \$iface,
- "want=s" => \$want);
-
-# Return the current router address from an interface that is
-# configured via dhcp. Return 127.0.0.1 for all errors.
-# This address will be used for the next hop address for static routes.
-
-sub get_dhcp_router {
- my $dhcp_iface = pop(@_);
- if (!Vyatta::Misc::is_dhcp_enabled($dhcp_iface,0)) {
- return "127.0.0.1";
- }
- my $lease = "/var/lib/dhcp/dhclient_${dhcp_iface}.lease";
- my $router = `grep new_routers= $lease | cut -d"'" -f2`;
- my @r = split(/,/, $router);
- $router = $r[0];
- # Make sure the result looks like a IP
- if ($router !~ /\d+\.\d+\.\d+\.\d+/) {
- return "127.0.0.1";
- }
- # Remove trailing newlines
- $router =~ s/\n$//;
- return $router;
-}
-
-
-# Return the current ipv4 address from an interface that is
-# configured via dhcp. Return 127.0.0.1 for all errors.
-# This address will be used for the local-ip for tunnels,
-
-sub get_dhcp_addr {
- my $dhcp_iface = pop(@_);
- if (!Vyatta::Misc::is_dhcp_enabled($dhcp_iface,0)) {
- return "127.0.0.1";
- }
- my @dhcp_addr = Vyatta::Misc::getIP($dhcp_iface,4);
- my $addr = pop(@dhcp_addr);
- if (!defined($addr)) {
- return "127.0.0.1";
- }
- @dhcp_addr = split(/\//, $addr);
- $addr = $dhcp_addr[0];
- return $addr;
-}
-
-
-if ($want eq 'local') {
- print get_dhcp_addr($iface);
-}
-else {
- print get_dhcp_router($iface);
-}
-exit 0;
-
diff --git a/scripts/vyatta-grub-setup b/scripts/vyatta-grub-setup
index 5dcf0809..91c5f061 100755
--- a/scripts/vyatta-grub-setup
+++ b/scripts/vyatta-grub-setup
@@ -41,13 +41,16 @@ version=""
UNION="false"
while getopts u:v: c
do
- case $c in
- u) UNION=true;
- livedir=$OPTARG;
- version=$livedir;;
-
- v) version=$OPTARG;;
- esac
+ case $c in
+ u)
+ UNION=true;
+ livedir=$OPTARG;
+ version=$livedir
+ ;;
+ v)
+ version=$OPTARG
+ ;;
+ esac
done
shift `expr $OPTIND - 1`
@@ -59,9 +62,9 @@ ROOTFSDIR="$3"
# Grub options
if [ "$GRUB_OPTIONS" ]; then
- GRUB_OPTIONS="$GRUB_OPTIONS rootdelay=5"
+ GRUB_OPTIONS="$GRUB_OPTIONS rootdelay=5"
else
- GRUB_OPTIONS="rootdelay=5"
+ GRUB_OPTIONS="rootdelay=5"
fi
# Path to standalone root password reset script
@@ -89,16 +92,24 @@ kernel_versions=$(ls $ROOTFSDIR/boot/vmlinuz-* 2> /dev/null | grep -v xen | awk
xen_kernel_version=$(ls $ROOTFSDIR/boot/vmlinuz*-xen* 2> /dev/null | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
xen_version=$(ls $ROOTFSDIR/boot/xen-*.gz 2> /dev/null | head -1 | awk -F/ '{ print $5 }' | sort -r)
+TTY=$(tty)
+if [ -n "$SUDO_USER" ]; then
+ DEV=$(sudo who | grep "$SUDO_USER" | grep tty | awk '{print $2;}')
+ if [ -n "$DEV" ]; then
+ TTY="/dev/$DEV"
+ fi
+fi
+
# Figure out whether we are running on the serial or KVM console:
-if [ "`tty`" == "/dev/ttyS0" ]; then
- # Since user is running on serial console, make that the default.
- default_console=1
-elif [ "`tty`" == "/dev/ttyUSB0" ]; then
- # Since user is running on usb console, make that the default.
- default_console=2
+if [ "$TTY" == "/dev/ttyS0" ]; then
+ # Since user is running on serial console, make that the default.
+ default_console=1
+elif [ "$TTY" == "/dev/ttyUSB0" ]; then
+ # Since user is running on usb console, make that the default.
+ default_console=2
else
- # Since user is running on KVM console, make that the default
- default_console=0
+ # Since user is running on KVM console, make that the default
+ default_console=0
fi
if eval "$UNION"; then
@@ -119,7 +130,7 @@ else
uuid=$(dumpe2fs -h /dev/${ROOT_PARTITION} 2>/dev/null | awk '/^Filesystem UUID/ {print $3}')
if [ -z "$uuid" ]
then
- # TODO: use /proc/mount if dumpe2fs fails
+ # TODO: use /proc/mount if dumpe2fs fails
echo "Unable to read filesystem UUID. Exiting."
exit 1
else
@@ -157,56 +168,56 @@ fi
# EFI needs a few extra modules
if [ -d /sys/firmware/efi ]; then
- echo -e "insmod efi_gop"
- echo -e "insmod efi_uga"
+ echo -e "insmod efi_gop"
+ echo -e "insmod efi_uga"
fi
if [ ${ROOT_PARTITION:0:2} = "md" ]; then
if [ -d /sys/firmware/efi ]; then
- uuid_root_disk=`/sbin/tune2fs -l /dev/${root_disk}3 | grep UUID | awk '{print $3}'`
+ uuid_root_disk=`/sbin/tune2fs -l /dev/${root_disk}3 | grep UUID | awk '{print $3}'`
else
- uuid_root_disk=`/sbin/tune2fs -l /dev/${root_disk}1 | grep UUID | awk '{print $3}'`
+ uuid_root_disk=`/sbin/tune2fs -l /dev/${root_disk}1 | grep UUID | awk '{print $3}'`
fi
- uuid_root_md=`/sbin/tune2fs -l /dev/md${ROOT_PARTITION#md} | grep UUID | awk '{print $3}'`
- echo ""
- echo -e "insmod part_msdos"
- echo -e "insmod diskfilter"
- echo -e "insmod ext2"
- echo -e "insmod mdraid1x"
- echo -e "set root='mduuid/${uuid_root_disk}'"
- echo -e "search --no-floppy --fs-uuid --set=root ${uuid_root_md}"
+ uuid_root_md=`/sbin/tune2fs -l /dev/md${ROOT_PARTITION#md} | grep UUID | awk '{print $3}'`
+ echo ""
+ echo -e "insmod part_msdos"
+ echo -e "insmod diskfilter"
+ echo -e "insmod ext2"
+ echo -e "insmod mdraid1x"
+ echo -e "set root='mduuid/${uuid_root_disk}'"
+ echo -e "search --no-floppy --fs-uuid --set=root ${uuid_root_md}"
fi
# create xen kernels if they exist
XEN_OPTS='dom0_mem=512M xenheap_megabytes=128'
if [ -n "$xen_kernel_version" ]; then
- for xversion in $xen_kernel_version; do
- echo
- echo
- echo -e "menuentry \"VyOS Xen linux$xversion dom0\" {"
- echo -e "\tmultiboot /boot/$xen_version $XEN_OPTS"
- echo -e "\tmodule /boot/vmlinuz$xversion $GRUB_OPTIONS $vty_console"
- echo -e "\tmodule /boot/initrd.img$xversion"
- echo -e "}"
- done
+ for xversion in $xen_kernel_version; do
+ echo
+ echo
+ echo -e "menuentry \"VyOS Xen linux$xversion dom0\" {"
+ echo -e "\tmultiboot /boot/$xen_version $XEN_OPTS"
+ echo -e "\tmodule /boot/vmlinuz$xversion $GRUB_OPTIONS $vty_console"
+ echo -e "\tmodule /boot/initrd.img$xversion"
+ echo -e "}"
+ done
fi
if [ -n "$union_xen_kernel_version" ]; then
- for xversion in $union_xen_kernel_version; do
- echo
- echo
- echo -e "menuentry \"VyOS Xen linux$xversion dom0\" {"
- echo -e "\tmultiboot /boot/$livedir/$union_xen_version $XEN_OPTS"
- echo -e "\tmodule /boot/$livedir/vmlinuz$xversion $GRUB_OPTIONS $vty_console"
- echo -e "\tmodule /boot/$livedir/initrd.img$xversion"
- echo -e "}"
- done
+ for xversion in $union_xen_kernel_version; do
+ echo
+ echo
+ echo -e "menuentry \"VyOS Xen linux$xversion dom0\" {"
+ echo -e "\tmultiboot /boot/$livedir/$union_xen_version $XEN_OPTS"
+ echo -e "\tmodule /boot/$livedir/vmlinuz$xversion $GRUB_OPTIONS $vty_console"
+ echo -e "\tmodule /boot/$livedir/initrd.img$xversion"
+ echo -e "}"
+ done
fi
if eval "$UNION"; then
- # UNION case
- if [ -e "$ROOTFSDIR/boot/$livedir/vmlinuz" -a \
- -e "$ROOTFSDIR/boot/$livedir/initrd.img" ]; then
+ # UNION case
+ if [ -e "$ROOTFSDIR/boot/$livedir/vmlinuz" -a \
+ -e "$ROOTFSDIR/boot/$livedir/initrd.img" ]; then
echo
echo -e "menuentry \"VyOS $version linux (KVM console)\" {"
echo -e "\tlinux /boot/$livedir/vmlinuz $GRUB_OPTIONS $VGA_LOGO $vty_console"
@@ -223,65 +234,65 @@ fi
echo -e "\tinitrd /boot/$livedir/initrd.img"
echo -e "}"
- elif [ -n "$union_kernel_versions" ]; then
- for kversion in $union_kernel_versions; do
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (KVM console)\" {"
- echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $VGA_LOGO $vty_console"
- echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
- echo -e "}"
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (Serial console)\" {"
- echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $serial_console"
- echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
- echo -e "}"
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (USB console)\" {"
- echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $usb_console"
- echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
- echo -e "}"
- done
- fi
+ elif [ -n "$union_kernel_versions" ]; then
+ for kversion in $union_kernel_versions; do
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (KVM console)\" {"
+ echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $VGA_LOGO $vty_console"
+ echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
+ echo -e "}"
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (Serial console)\" {"
+ echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $serial_console"
+ echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
+ echo -e "}"
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (USB console)\" {"
+ echo -e "\tlinux /boot/$livedir/vmlinuz$kversion $GRUB_OPTIONS $usb_console"
+ echo -e "\tinitrd /boot/$livedir/initrd.img$kversion"
+ echo -e "}"
+ done
+ fi
else
- # Non-UNION case
- if [ -f "$ROOTFSDIR/boot/vmlinuz" ]; then
+ # Non-UNION case
+ if [ -f "$ROOTFSDIR/boot/vmlinuz" ]; then
# Set first system boot option. Make KVM the default console in this one.
- echo -e "menuentry \"VyOS $version (KVM console)\" {"
- echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $VGA_LOGO $vty_console"
- echo -e "\tinitrd /boot/initrd.img"
- echo -e "}"
+ echo -e "menuentry \"VyOS $version (KVM console)\" {"
+ echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $VGA_LOGO $vty_console"
+ echo -e "\tinitrd /boot/initrd.img"
+ echo -e "}"
# Set the second system boot option.
- # Make the serial port be the default console in this one.
- echo
- echo -e "menuentry \"VyOS $version (Serial console)\" {"
- echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $serial_console"
- echo -e "\tinitrd /boot/initrd.img"
- echo -e "}"
- echo
- echo -e "menuentry \"VyOS $version (USB console)\" {"
- echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $usb_console"
- echo -e "\tinitrd /boot/initrd.img"
- echo -e "}"
- elif [ -n "$kernel_versions" ]; then
- for kversion in $kernel_versions; do
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (KVM console)\" {"
- echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $VGA_LOGO $vty_console"
- echo -e "\tinitrd /boot/initrd.img$kversion"
- echo -e "}"
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (Serial console)\" {"
- echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $serial_console"
- echo -e "\tinitrd /boot/initrd.img$kversion"
- echo -e "}"
- echo
- echo -e "menuentry \"VyOS $version linux$kversion (USB console)\" {"
- echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $usb_console"
- echo -e "\tinitrd /boot/initrd.img$kversion"
- echo -e "}"
- done
- fi
+ # Make the serial port be the default console in this one.
+ echo
+ echo -e "menuentry \"VyOS $version (Serial console)\" {"
+ echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $serial_console"
+ echo -e "\tinitrd /boot/initrd.img"
+ echo -e "}"
+ echo
+ echo -e "menuentry \"VyOS $version (USB console)\" {"
+ echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $usb_console"
+ echo -e "\tinitrd /boot/initrd.img"
+ echo -e "}"
+ elif [ -n "$kernel_versions" ]; then
+ for kversion in $kernel_versions; do
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (KVM console)\" {"
+ echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $VGA_LOGO $vty_console"
+ echo -e "\tinitrd /boot/initrd.img$kversion"
+ echo -e "}"
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (Serial console)\" {"
+ echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $serial_console"
+ echo -e "\tinitrd /boot/initrd.img$kversion"
+ echo -e "}"
+ echo
+ echo -e "menuentry \"VyOS $version linux$kversion (USB console)\" {"
+ echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_OPTIONS $usb_console"
+ echo -e "\tinitrd /boot/initrd.img$kversion"
+ echo -e "}"
+ done
+ fi
fi
# Set options for root password reset. Offer
@@ -312,6 +323,6 @@ fi
) >"$ROOTFSDIR"/boot/grub/grub.cfg
( [ -s /boot/grub/menu.lst ] &&
- upgrade-from-grub-legacy &&
- rm -f /boot/grub/menu.lst*
+ upgrade-from-grub-legacy &&
+ rm -f /boot/grub/menu.lst*
) || true
diff --git a/scripts/vyatta-raid-event b/scripts/vyatta-raid-event
deleted file mode 100755
index 2c193da5..00000000
--- a/scripts/vyatta-raid-event
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/bash
-#
-# **** 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: Bob Gilligan <gilligan@vyatta.com>
-# Date: 2008
-# Description: A script to handle events from the Linux Software RAID
-# subsystem.
-#
-# **** End License ****
-#
-# This script is called by the "mdadm" daemon running in "monitor" mode
-# whenever an event occurs in in the RAID subsytem. The script is called
-# with two or three arguments: The first argument is always the name of
-# the event, e.g. "RebuildFinished". The second argument is the name of
-# the RAID set device that the event pertains to, e.g. "/dev/md0". The
-# third argument is provided for some events, and gives the name of the
-# RAID set member that the event pertains to, e.g. "/dev/sda2".
-#
-# See the mdadm(8) man page for more details on the events that it provides.
-#
-
-# Script will be called with 2 or 3 arguments, depending on the event
-if [ $# -lt 2 ]; then
- logger -t "RAID" -p local0.warning "vyatta-raid-event: Error: Not enough args: $*"
- # We can't do anything if we don't know event and RAID device it
- # pertains to.
- exit 1
-fi
-if [ $# -gt 3 ]; then
- logger -t "RAID" -p local0.warning "vyatta-raid-event: Warning: too many args: $*"
- # Be Robust: Try to complete task with args we know about
-fi
-
-event=$1
-raid_set=$2
-
-case $event in
-
- RebuildFinished)
- logger -t "RAID" -p local0.warning "event ${event} ${raid_set}"
-
- # We need to update grub at the time that a resync completes
- # on the root filesystem so that the new member disk will be
- # bootable.
- root_dir=/
- mounted_on_root=0
- mounted_on=`mount | grep "^${raid_set}" | awk '{ print $3 }'`
- for dir in $mounted_on ; do
- if [ "$dir" = "/" -o "$dir" = "/live/image" ]; then
- mounted_on_root=1
- root_dir=$dir
- fi
- done
-
- if [ $mounted_on_root -eq 1 ]; then
- raid_set_dev=${raid_set##*/}
- if [ -e /sys/block/${raid_set_dev}/md/degraded ]; then
- degraded=`cat /sys/block/${raid_set_dev}/md/degraded`
- else
- degraded=0
- fi
- if [ $degraded -eq 0 ]; then
- drive=${member_to_add%%[0-9]*}
- logger -t "RAID" -p local0.warning \
- "RAID set ${raid_set} holds root filesystem. Updating grub."
- touch /tmp/raid-grub-install-log
- grub-install --no-floppy --recheck --root-directory=${root_dir} ${raid_set} \
- >> /tmp/raid-grub-install-log 2>&1
- if [ $? -ne 0 ]; then
- logger -t "RAID" -p local0.warning \
- "grub-installed failed for $raid_set"
- fi
- else
- logger -t "RAID" -p local0.warning \
- "RAID set ${raid_set} is still degraded. No action taken."
- fi
- else
- logger -t "RAID" -p local0.warning \
- "RAID set ${raid_set} does not hold root filesystem. No action taken"
- fi
- ;;
-
- DeviceDisappeared | RebuildStarted | Rebuild?? | NewArray | \
- DegradedArray | MoveSpare | SparesMissing | TestMessage)
- logger -t "RAID" -p local0.warning \
- "event ${event} ${raid_set}: No action taken"
- ;;
-
- Fail | FailSpare | SpareActive)
- member=$3
- logger -t "RAID" -p local0.warning \
- "event ${event} ${raid_set} ${member}: No action taken"
- ;;
-
- *)
- logger -t "RAID" -p local0.warning \
- "event ${event} unknown. No action taken"
- ;;
-
- esac
diff --git a/scripts/vyatta-tunnel-cleanup b/scripts/vyatta-tunnel-cleanup
deleted file mode 100755
index b8a93244..00000000
--- a/scripts/vyatta-tunnel-cleanup
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/perl
-
-# This script gets run after tunnels have been deleted, it removes
-# the underlying tunnel link, if all tunnels of that type are gone.
-
-use strict;
-use warnings;
-use lib "/opt/vyatta/share/perl5";
-use Vyatta::Config;
-
-# encapsulations and module names
-my %encapsulation = (
- 'gre' => 'ip_gre',
- 'ipip' => 'ipip',
- 'sit' => 'sit',
-);
-
-# interface being deleted
-my $interface = $ARGV[0];
-
-# Create map of encapsulations still in use
-my $config = new Vyatta::Config;
-$config->setLevel("interfaces tunnel");
-
-my %tunnel;
-foreach my $tun ( $config->listEffectiveNodes() ) {
- my $mode = $config->returnEffectiveValue("$tun encapsulation");
- next if ($interface eq $tun); # don't count the one being deleted
- $tunnel{$mode} = 1;
-}
diff --git a/scripts/vyatta-tunnel-dhcp.pl b/scripts/vyatta-tunnel-dhcp.pl
deleted file mode 100644
index cc51483d..00000000
--- a/scripts/vyatta-tunnel-dhcp.pl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl
-use Getopt::Long;
-use strict;
-
-my ($iface, $dhcp, $tunnel, $nip, $oip, $reason);
-GetOptions("interface=s" => \$iface,
- "dhcp=s" => \$dhcp,
- "tunnel=s" => \$tunnel,
- "new_ip=s" => \$nip,
- "old_ip=s" => \$oip,
- "reason=s" => \$reason);
-
-# check if an update is needed
-if (($reason eq "BOUND") || ($reason eq "REBOOT")) {
- $oip = "";
-}
-exit(0) if (($iface ne $dhcp) || ($oip eq $nip));
-logger("DHCP address on $iface updated to $nip from $oip: Updating tunnel $tunnel configuration.");
-system("sudo ip tunnel change $tunnel local $nip");
-
-sub logger {
- my $msg = pop(@_);
- my $FACILITY = "daemon";
- my $LEVEL = "notice";
- my $TAG = "tunnel-dhclient-hook";
- my $LOGCMD = "logger -t $TAG -p $FACILITY.$LEVEL";
- system("$LOGCMD $msg");
-}
diff --git a/scripts/vyatta-update-tunnel.pl b/scripts/vyatta-update-tunnel.pl
deleted file mode 100644
index de5019ab..00000000
--- a/scripts/vyatta-update-tunnel.pl
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Long;
-use strict;
-use lib "/opt/vyatta/share/perl5";
-use Vyatta::Config;
-
-my ($iface, $tunnel, $option);
-GetOptions("interface=s" => \$iface,
- "tunnel=s" => \$tunnel,
- "option=s" => \$option
- );
-my $FILE_DHCP_HOOK = "/etc/dhcp/dhclient-exit-hooks.d/tunnel-$tunnel";
-my $dhcp_hook = '';
-if ($option eq 'create') {
- $dhcp_hook =<<EOS;
-#!/bin/sh
-/opt/vyatta/bin/sudo-users/vyatta-tunnel-dhcp.pl --interface=\"\$interface\" --dhcp=\"$iface\" --tunnel=\"$tunnel\" --new_ip=\"\$new_ip_address\" --old_ip=\"\$old_ip_address\" --reason=\"\$reason\"
-EOS
-}
-
-open my $dhcp_hook_file, '>', $FILE_DHCP_HOOK
- or die "cannot open $FILE_DHCP_HOOK";
-print ${dhcp_hook_file} $dhcp_hook;
-close $dhcp_hook_file;
-exit 0;
-