mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 00:07:16 +00:00
refactor: Move more functions to script library
Moved the display functions to the script library to avoid duplication. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
a18753b2ff
commit
019a80f304
@ -11,35 +11,13 @@ set -e
|
|||||||
script_name="${0##*/}"
|
script_name="${0##*/}"
|
||||||
script_dir="$(dirname $(readlink -f $0))"
|
script_dir="$(dirname $(readlink -f $0))"
|
||||||
|
|
||||||
|
lib_file="${script_dir}/../scripts/lib.sh"
|
||||||
|
source "$lib_file"
|
||||||
|
|
||||||
IMAGE="${IMAGE:-kata-containers.img}"
|
IMAGE="${IMAGE:-kata-containers.img}"
|
||||||
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
||||||
AGENT_INIT=${AGENT_INIT:-no}
|
AGENT_INIT=${AGENT_INIT:-no}
|
||||||
|
|
||||||
die()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "ERROR: ${msg}" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
OK()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "[OK] ${msg}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
info()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "INFO: ${msg}"
|
|
||||||
}
|
|
||||||
|
|
||||||
warning()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "WARNING: ${msg}"
|
|
||||||
}
|
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
error="${1:-0}"
|
error="${1:-0}"
|
||||||
|
@ -11,29 +11,13 @@ set -e
|
|||||||
script_name="${0##*/}"
|
script_name="${0##*/}"
|
||||||
script_dir="$(dirname $(readlink -f $0))"
|
script_dir="$(dirname $(readlink -f $0))"
|
||||||
|
|
||||||
|
lib_file="${script_dir}/../scripts/lib.sh"
|
||||||
|
source "$lib_file"
|
||||||
|
|
||||||
INITRD_IMAGE="${INITRD_IMAGE:-kata-containers-initrd.img}"
|
INITRD_IMAGE="${INITRD_IMAGE:-kata-containers-initrd.img}"
|
||||||
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
||||||
AGENT_INIT=${AGENT_INIT:-no}
|
AGENT_INIT=${AGENT_INIT:-no}
|
||||||
|
|
||||||
die()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "ERROR: ${msg}" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
OK()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "[OK] ${msg}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
info()
|
|
||||||
{
|
|
||||||
local msg="$*"
|
|
||||||
echo "INFO: ${msg}"
|
|
||||||
}
|
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
error="${1:-0}"
|
error="${1:-0}"
|
||||||
|
@ -16,6 +16,9 @@ AGENT_BIN=${AGENT_BIN:-kata-agent}
|
|||||||
AGENT_INIT=${AGENT_INIT:-no}
|
AGENT_INIT=${AGENT_INIT:-no}
|
||||||
KERNEL_MODULES_DIR=${KERNEL_MODULES_DIR:-""}
|
KERNEL_MODULES_DIR=${KERNEL_MODULES_DIR:-""}
|
||||||
|
|
||||||
|
lib_file="${script_dir}/../scripts/lib.sh"
|
||||||
|
source "$lib_file"
|
||||||
|
|
||||||
# Default architecture
|
# Default architecture
|
||||||
ARCH=${ARCH:-"x86_64"}
|
ARCH=${ARCH:-"x86_64"}
|
||||||
|
|
||||||
@ -60,25 +63,6 @@ EOT
|
|||||||
exit "${error}"
|
exit "${error}"
|
||||||
}
|
}
|
||||||
|
|
||||||
die()
|
|
||||||
{
|
|
||||||
msg="$*"
|
|
||||||
echo "ERROR: ${msg}" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
info()
|
|
||||||
{
|
|
||||||
msg="$*"
|
|
||||||
echo "INFO: ${msg}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
OK()
|
|
||||||
{
|
|
||||||
msg="$*"
|
|
||||||
echo "INFO: [OK] ${msg}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
get_distros() {
|
get_distros() {
|
||||||
cdirs=$(find "${script_dir}" -maxdepth 1 -type d)
|
cdirs=$(find "${script_dir}" -maxdepth 1 -type d)
|
||||||
find ${cdirs} -maxdepth 1 -name "${CONFIG_SH}" -printf '%H\n' | while read dir; do
|
find ${cdirs} -maxdepth 1 -name "${CONFIG_SH}" -printf '%H\n' | while read dir; do
|
||||||
@ -174,10 +158,6 @@ distro_config_dir="${script_dir}/${distro}"
|
|||||||
rootfs_config="${distro_config_dir}/${CONFIG_SH}"
|
rootfs_config="${distro_config_dir}/${CONFIG_SH}"
|
||||||
source "${rootfs_config}"
|
source "${rootfs_config}"
|
||||||
|
|
||||||
lib_file="${script_dir}/../scripts/lib.sh"
|
|
||||||
info "Source $lib_file"
|
|
||||||
[ -e "$lib_file" ] && source "$lib_file" || true
|
|
||||||
|
|
||||||
[ -d "${distro_config_dir}" ] || die "Not found configuration directory ${distro_config_dir}"
|
[ -d "${distro_config_dir}" ] || die "Not found configuration directory ${distro_config_dir}"
|
||||||
|
|
||||||
if [ -z "$ROOTFS_DIR" ]; then
|
if [ -z "$ROOTFS_DIR" ]; then
|
||||||
|
@ -6,7 +6,33 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
check_program(){
|
die()
|
||||||
|
{
|
||||||
|
local msg="$*"
|
||||||
|
echo "ERROR: ${msg}" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
OK()
|
||||||
|
{
|
||||||
|
local msg="$*"
|
||||||
|
echo "[OK] ${msg}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
info()
|
||||||
|
{
|
||||||
|
local msg="$*"
|
||||||
|
echo "INFO: ${msg}"
|
||||||
|
}
|
||||||
|
|
||||||
|
warning()
|
||||||
|
{
|
||||||
|
local msg="$*"
|
||||||
|
echo "WARNING: ${msg}"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_program()
|
||||||
|
{
|
||||||
type "$1" >/dev/null 2>&1
|
type "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user