[Doc] Usage and ISO Check Common Code

Usage function and ISO file checking are common between all-in-one
and standard controller setups.

Make both scripts shared same code located at a functions file.

Change-Id: Ic47072be8f9d646ef1dcaf9193453dfcd4534783
Signed-off-by: Abraham Arce <abraham.arce.moreno@intel.com>
This commit is contained in:
Abraham Arce 2018-10-30 07:20:31 -06:00
parent dd66d0e957
commit 3c0f9b11ea
3 changed files with 23 additions and 32 deletions

View File

@ -1,5 +1,22 @@
#!/usr/bin/env bash
usage() {
echo "$0 [-h] [-i <iso image>]"
echo ""
echo "Options:"
echo " -i: StarlingX ISO image"
echo ""
}
iso_image_check() {
local ISOIMAGE=$1
FILETYPE=$(file --mime-type -b ${ISOIMAGE})
if ([ "$FILETYPE" != "application/x-iso9660-image" ]); then
echo "$ISOIMAGE is not an application/x-iso9660-image type"
exit -1
fi
}
# delete a node's disk file in a safe way
delete_disk() {
local fpath="$1"

View File

@ -1,19 +1,12 @@
#!/usr/bin/env bash
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
usage() {
echo "$0 [-h] [-i <iso image>]"
echo ""
echo "Options:"
echo " -i: StarlingX ISO image"
echo ""
}
source ${SCRIPT_DIR}/functions.sh
while getopts "i:" o; do
case "${o}" in
i)
ISOIMAGE="$OPTARG"
ISOIMAGE=$(readlink -f "$OPTARG")
;;
*)
usage
@ -28,12 +21,7 @@ if [ -z "${ISOIMAGE}" ]; then
exit -1
fi
ISOIMAGE=$(readlink -f "$ISOIMAGE")
FILETYPE=$(file --mime-type -b ${ISOIMAGE})
if ([ "$FILETYPE" != "application/x-iso9660-image" ]); then
echo "$ISOIMAGE is not an application/x-iso9660-image type"
exit -1
fi
iso_image_check ${ISOIMAGE}
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
CONTROLLER=${CONTROLLER:-controller-allinone}

View File

@ -1,21 +1,12 @@
#!/usr/bin/env bash
#set -x
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
usage() {
echo "$0 [-h] [-i <iso image>]"
echo ""
echo "Options:"
echo " -i: StarlingX ISO image"
echo ""
}
source ${SCRIPT_DIR}/functions.sh
while getopts "i:" o; do
case "${o}" in
i)
ISOIMAGE="$OPTARG"
ISOIMAGE=$(readlink -f "$OPTARG")
;;
*)
usage
@ -30,12 +21,7 @@ if [ -z "${ISOIMAGE}" ]; then
exit -1
fi
ISOIMAGE=$(readlink -f "$ISOIMAGE")
FILETYPE=$(file --mime-type -b ${ISOIMAGE})
if ([ "$FILETYPE" != "application/x-iso9660-image" ]); then
echo "$ISOIMAGE is not an application/x-iso9660-image type"
exit -1
fi
iso_image_check ${ISOIMAGE}
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
CONTROLLER=${CONTROLLER:-controller}