Call which from virtualbox scripts
The "which" command is replaced with the "type" command. The free memory check error on the host has been fixed. Change-Id: I2cb8d143616372b649d51b9543160d40e5f2f510 Closes-Bug: #1415685
This commit is contained in:
parent
5494f985f6
commit
7ddf69872f
|
@ -18,11 +18,14 @@
|
||||||
# This script check availble memory on host PC for quality provision VMs via VirtualBox
|
# This script check availble memory on host PC for quality provision VMs via VirtualBox
|
||||||
#
|
#
|
||||||
|
|
||||||
total_memory=$(get_available_memory $os_type)
|
source ./config.sh
|
||||||
|
source ./functions/memory.sh
|
||||||
|
|
||||||
|
total_memory=$(get_available_memory)
|
||||||
|
|
||||||
if [ $total_memory -eq -1 ]; then
|
if [ $total_memory -eq -1 ]; then
|
||||||
echo "Launch without checking RAM on host PC"
|
echo "Launch without checking RAM on host PC"
|
||||||
echo "Auto check memory is unavailable, you need install 'top' and 'free'. Please install procps package."
|
echo "Auto check memory is unavailable, you need install 'free'. Please install procps package."
|
||||||
else
|
else
|
||||||
# Count selected RAM configuration
|
# Count selected RAM configuration
|
||||||
for machine_number in $(eval echo {1..$cluster_size}); do
|
for machine_number in $(eval echo {1..$cluster_size}); do
|
||||||
|
@ -41,4 +44,4 @@ else
|
||||||
echo "You can allocate no more than ${can_allocate_mb}MB, but trying to run VMs with ${vm_total_mb}MB"
|
echo "You can allocate no more than ${can_allocate_mb}MB, but trying to run VMs with ${vm_total_mb}MB"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -29,24 +29,37 @@ source ./functions/network.sh
|
||||||
|
|
||||||
# Check for procps package
|
# Check for procps package
|
||||||
if [ "$(uname -s | cut -c1-6)" = "CYGWIN" ]; then
|
if [ "$(uname -s | cut -c1-6)" = "CYGWIN" ]; then
|
||||||
echo -n "Checking for 'top' and 'free'"
|
echo -n "Checking for 'free'... "
|
||||||
free -V >/dev/null 2>&1 || { echo >&2 " \"free\" is not available in the path, but it's required. Please install \"procps\" package. Aborting."; exit 1; }
|
type free >/dev/null 2>&1
|
||||||
top -v >/dev/null 2>&1 || { echo >&2 " \"top\" is not available in the path, but it's required. Please install \"procps\" package. Aborting."; exit 1; }
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "\"free\" is not available in the path, but it's required. Please install the \"procps\" package. Aborting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for expect
|
# Check for expect
|
||||||
echo -n "Checking for 'expect'... "
|
echo -n "Checking for 'expect'... "
|
||||||
expect -v >/dev/null 2>&1 || { echo >&2 " \"expect\" is not available in the path, but it's required. Please install Tcl \"expect\" package. Aborting."; exit 1; }
|
type expect >/dev/null 2>&1
|
||||||
echo "OK"
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "\"expect\" is not available in the path, but it's required. Please install Tcl \"expect\" package. Aborting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for VirtualBox
|
# Check for VirtualBox
|
||||||
echo "If you run this script under Cygwin, you may have to add path to VirtualBox directory to your PATH. "
|
echo "If you run this script under Cygwin, you may have to add path to VirtualBox directory to your PATH. "
|
||||||
echo "Usually it is enough to run \"export PATH=\$PATH:\"/cygdrive/c/Program Files/Oracle/VirtualBox\" "
|
echo "Usually it is enough to run \"export PATH=\$PATH:\"/cygdrive/c/Program Files/Oracle/VirtualBox\" "
|
||||||
echo -n "Checking for \"VBoxManage\"... "
|
echo -n "Checking for \"VBoxManage\"... "
|
||||||
echo -n " "
|
type VBoxManage >/dev/null 2>&1
|
||||||
VBoxManage -v >/dev/null 2>&1 || { echo >&2 "\"VBoxManage\" is not available in the path, but it's required. Likely, VirtualBox is not installed. Aborting."; exit 1; }
|
if [ $? -eq 1 ]; then
|
||||||
echo "OK"
|
echo "\"VBoxManage\" is not available in the path, but it's required. Likely, VirtualBox is not installed. Aborting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for VirtualBox Extension Pack
|
# Check for VirtualBox Extension Pack
|
||||||
echo -n "Checking for VirtualBox Extension Pack... "
|
echo -n "Checking for VirtualBox Extension Pack... "
|
||||||
|
@ -66,29 +79,30 @@ echo "OK"
|
||||||
echo "Going to use Mirantis OpenStack ISO file $iso_path"
|
echo "Going to use Mirantis OpenStack ISO file $iso_path"
|
||||||
|
|
||||||
# Check if SSH is installed. Cygwin does not install SSH by default.
|
# Check if SSH is installed. Cygwin does not install SSH by default.
|
||||||
echo "Checking if SSH client installed... "
|
echo -n "Checking if SSH client installed... "
|
||||||
sshs=`which ssh | wc -l`
|
type ssh >/dev/null 2>&1
|
||||||
if [ "$sshs" -le 0 ] ; then
|
if [ $? -eq 1 ]; then
|
||||||
echo -n "SSH client is not installed. Please install \"openssh\" package if you run this script under Cygwin. Aborting"
|
echo "SSH client is not installed. Please install the \"openssh\" package if you run this script under Cygwin. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
echo "OK"
|
|
||||||
|
|
||||||
echo "Checking if ipconfig or ifconfig installed... "
|
echo -n "Checking if ipconfig or ifconfig installed... "
|
||||||
case "$(uname)" in
|
case "$(uname)" in
|
||||||
Linux | Darwin)
|
Linux | Darwin)
|
||||||
if [ ! -x /sbin/ifconfig ] ; then
|
if [ ! -x /sbin/ifconfig ] ; then
|
||||||
echo -n "No ifconfig available at /sbin/ifconfig path! This path is hard-coded into VBoxNetAdpCtl utility."
|
echo "No ifconfig available at /sbin/ifconfig path! This path is hard-coded into VBoxNetAdpCtl utility."
|
||||||
echo -n "Please install ifconfig or create symlink to proper interface configuration utility."
|
echo "Please install ifconfig or create symlink to proper interface configuration utility. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
# Cygwin does not use ifconfig at all and even has no link to it.
|
# Cygwin does not use ifconfig at all and even has no link to it.
|
||||||
# It uses built-in Windows ipconfig utility instead.
|
# It uses built-in Windows ipconfig utility instead.
|
||||||
ipconfigs=`which ipconfig | wc -l`
|
type ipconfig >/dev/null 2>&1
|
||||||
if [ "$ipconfigs" -le 0 ] ; then
|
if [ $? -eq 1 ]; then
|
||||||
echo -n "No ipconfig available in Cygwin environment. Please check you can run ipconfig from Cygwin command prompt."
|
echo "No ipconfig available in Cygwin environment. Please check you can run ipconfig from Cygwin command prompt. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -17,40 +17,18 @@
|
||||||
# This file contains the functions to get available memory on host PC
|
# This file contains the functions to get available memory on host PC
|
||||||
|
|
||||||
get_available_memory() {
|
get_available_memory() {
|
||||||
os_type=$1
|
local total_memory
|
||||||
local total_memory=""
|
case $(uname) in
|
||||||
# Check available commands and RAM on host PC
|
Linux | CYGWIN*)
|
||||||
if [ "$os_type" = "linux" ]; then
|
|
||||||
# runing on linux
|
|
||||||
if [ "$(which free)" != "" ]; then
|
|
||||||
# using free
|
|
||||||
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
|
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
|
||||||
elif [ "$(which top)" != "" ]; then
|
;;
|
||||||
# using top
|
Darwin)
|
||||||
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
|
|
||||||
else
|
|
||||||
total_memory="-1"
|
|
||||||
fi
|
|
||||||
elif [ "$os_type" = "darwin" ]; then
|
|
||||||
# runing on mac os darwin
|
|
||||||
if [ "$(which sysctl)" != "" ]; then
|
|
||||||
# using sysctl
|
|
||||||
total_memory=$(sysctl -n hw.memsize)
|
total_memory=$(sysctl -n hw.memsize)
|
||||||
total_memory=$(( $total_memory / 1024 ))
|
total_memory=$(( $total_memory / 1024 ))
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
total_memory="-1"
|
total_memory="-1"
|
||||||
fi
|
;;
|
||||||
elif [ "$os_type" = "cygwin" ]; then
|
esac
|
||||||
# runing on cygwin
|
|
||||||
if [ "$(which free)" != "" ]; then
|
|
||||||
# using free
|
|
||||||
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
|
|
||||||
elif [ "$(which top)" != "" ]; then
|
|
||||||
# using top
|
|
||||||
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
|
|
||||||
else
|
|
||||||
total_memory="-1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo $total_memory
|
echo $total_memory
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,15 @@ esac
|
||||||
# Prepare the host system
|
# Prepare the host system
|
||||||
./actions/prepare-environment.sh || exit 1
|
./actions/prepare-environment.sh || exit 1
|
||||||
|
|
||||||
|
# Check available memory on the host system
|
||||||
|
./actions/check-available-memory.sh || exit 1
|
||||||
|
|
||||||
# clean previous installation if exists
|
# clean previous installation if exists
|
||||||
./actions/clean-previous-installation.sh || exit 1
|
./actions/clean-previous-installation.sh || exit 1
|
||||||
|
|
||||||
# create host-only interfaces
|
# create host-only interfaces
|
||||||
./actions/create-interfaces.sh || exit 1
|
./actions/create-interfaces.sh || exit 1
|
||||||
|
|
||||||
|
|
||||||
# Create and launch master node
|
# Create and launch master node
|
||||||
./actions/master-node-create-and-install.sh || exit 1
|
./actions/master-node-create-and-install.sh || exit 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue