summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/install-system39
-rwxr-xr-xscripts/install/install-functions38
-rwxr-xr-xscripts/vyatta-bonding.pl8
-rwxr-xr-xscripts/vyatta-bridge.pl8
4 files changed, 28 insertions, 65 deletions
diff --git a/scripts/install-system b/scripts/install-system
index 63a5d3d5..536233d7 100755
--- a/scripts/install-system
+++ b/scripts/install-system
@@ -143,45 +143,18 @@ get_response () {
# Return the size of the drive in MB
get_drive_size () {
- ldrive=$1
-
- # Make sure you can print disk info using parted
- parted --script /dev/$ldrive print >/dev/null 2>&1
+ local ldrive=$1
- # If unable to read disk, it's likely it needs a disklabel
- if [ "$?" != "0" ]; then
- echo "Creating a new disklabel on $ldrive" >> $INSTALL_LOG
- echo "parted /dev/$ldrive mklabel msdos" >> $INSTALL_LOG
- output=$(parted -s /dev/$ldrive mklabel msdos)
+ # Get size of disk in 1k blocks
+ local blocks=$(sfdisk -s /dev/$ldrive)
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
-
- if [ $(echo $lsize | grep error) ]; then
- echo "Unable to read disk label. Exiting."
- exit 1
- fi
- fi
-
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
- # Get the reported units (mB, GB, kB)
- lmodifier=$(echo $lsize | sed 's/[0-9\.]//g')
- # remove the modifier
- lsize=$(echo $lsize | sed 's/[a-z,A-Z]//g')
- # Remove any fractions
- lsize=$(echo $lsize | cut -f1 -d'.')
- # Translate our size into mB if not there already
- if [ $lmodifier = "GB" ]; then
- lsize=$(($lsize * 1000))
- elif [ $lmodifier = "kB" ]; then
- lsize=$(($lsize / 1000))
- fi
+ # Translate to Megabytes (SI units)
+ local bytes=$(($blocks * 1024))
+ local lsize=$(($bytes / 1000000))
echo $lsize
}
-
# Probe hardrives not shown in /proc/partitions by default
probe_drives () {
# Find drives that may not be in /proc/partitions since not mounted
diff --git a/scripts/install/install-functions b/scripts/install/install-functions
index 0cca8944..042ef5bb 100755
--- a/scripts/install/install-functions
+++ b/scripts/install/install-functions
@@ -139,40 +139,14 @@ turnoffswap () {
# Return the size of the drive in MB
get_drive_size () {
- ldrive=$1
+ local ldrive=$1
- # Make sure you can print disk info using parted
- parted --script /dev/$ldrive p >/dev/null 2>&1
+ # Get size of disk in 1k blocks
+ local blocks=$(sfdisk -s /dev/$ldrive)
- # If unable to read disk, it's likely it needs a disklabel
- if [ "$?" != "0" ]; then
- lecho "Creating a new disklabel on $ldrive"
- lecho "parted /dev/$ldrive mklabel msdos"
- output=$(parted -s /dev/$ldrive mklabel msdos)
-
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
-
- if [ $(echo $lsize | grep error) ]; then
- echo "Unable to read disk label. Exiting."
- exit 1
- fi
- fi
-
- # Get the drive size from parted
- lsize=$(parted -s /dev/$ldrive p | grep "^Disk" | awk '{ print $3 }')
- # Get the reported units (mB, GB, kB)
- lmodifier=$(echo $lsize | sed 's/[0-9\.]//g')
- # remove the modifier
- lsize=$(echo $lsize | sed 's/[a-z,A-Z]//g')
- # Remove any fractions
- lsize=$(echo $lsize | cut -f1 -d'.')
- # Translate our size into mB if not there already
- if [ $lmodifier = "GB" ]; then
- lsize=$(($lsize * 1000))
- elif [ $lmodifier = "kB" ]; then
- lsize=$(($lsize / 1000))
- fi
+ # Translate to Megabytes (SI units)
+ local bytes=$(($blocks * 1024))
+ local lsize=$(($bytes / 1000000))
echo $lsize
}
diff --git a/scripts/vyatta-bonding.pl b/scripts/vyatta-bonding.pl
index 71707126..aa733b61 100755
--- a/scripts/vyatta-bonding.pl
+++ b/scripts/vyatta-bonding.pl
@@ -225,6 +225,14 @@ sub commit_check {
my @vrrp = $cfg->listNodes('vrrp vrrp-group');
die "Error: can not add interface $slave with VRRP to bond-group\n"
if (@vrrp);
+
+ $cfg->setLevel('interfaces pseudo-ethernet');
+ foreach my $peth ($cfg->listNodes()) {
+ my $link = $cfg->returnValue("$peth link");
+
+ die "Error: can not add interface $slave to bond-group already used by pseudo-ethernet $peth\n"
+ if ($link eq $slave);
+ }
}
# bonding requires interface to be down before enslaving
diff --git a/scripts/vyatta-bridge.pl b/scripts/vyatta-bridge.pl
index bb0d41c3..68d3e107 100755
--- a/scripts/vyatta-bridge.pl
+++ b/scripts/vyatta-bridge.pl
@@ -68,6 +68,14 @@ if ( $action eq 'SET' ) {
die "Error: Can not add interface $ifname with VRRP to bridge\n"
if (@vrrp);
+ $cfg->setLevel('interfaces pseudo-ethernet');
+ foreach my $peth ($cfg->listNodes()) {
+ my $link = $cfg->returnValue("$peth link");
+
+ die "Error: can not add interface $slave to bridge already used by pseudo-ethernet $peth\n"
+ if ($link eq $slave);
+ }
+
print "Adding interface $ifname to bridge $newbridge\n";
add_bridge_port($newbridge, $ifname, $cost, $priority);