forked from NationTech/harmony
126 lines
2.2 KiB
Bash
Executable File
126 lines
2.2 KiB
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# virt-install <= virtinst
|
|
# quemu-img
|
|
|
|
|
|
|
|
harmony-ve-dependencies()(
|
|
|
|
set -eu
|
|
|
|
[ "${1:-}" != "-d" ] || { set -x ; shift ; }
|
|
trap '[ "$?" = "0" ] || >&2 echo ABNORMAL TERMINATION' EXIT
|
|
|
|
SCRIPTS_DIR=$(readlink -f "$(dirname "${BASH_SOURCE}")")
|
|
. "${SCRIPTS_DIR}/common"
|
|
_short_help(){
|
|
|
|
cat <<-EOM
|
|
|
|
NAME
|
|
|
|
harmony-ve-dependencies
|
|
|
|
DESCRIPTION
|
|
|
|
Manage localhost dependencies needed for Harmony Virtual Execution Environment
|
|
|
|
SYNOPSYS
|
|
|
|
devops-dependencies [GLOBAL_OPTIONS] COMMAND [OPTIONS]
|
|
|
|
devops check # Check that dependencies are installed
|
|
devops install # Install missing dependencies
|
|
|
|
EOM
|
|
|
|
}
|
|
|
|
_extra_help(){
|
|
|
|
cat <<-EOM
|
|
|
|
GLOBAL_OPTIONS
|
|
|
|
-d Debug mode.
|
|
|
|
WARNINGS
|
|
|
|
This script is experimetal. Use with caution.
|
|
EOM
|
|
|
|
}
|
|
|
|
|
|
_check_dependencies(){
|
|
. "${SCRIPTS_DIR}/dependencies-management"
|
|
missing=0
|
|
NEED_IP=false
|
|
NEED_KVM=false
|
|
NEED_VIRT_CUSTOMIZE=false
|
|
NEED_WGET=false
|
|
is_debian_family || _fatal only debian based version is supported
|
|
has_ip || {
|
|
missing=$(( missing + 1));
|
|
_warn "ip command is missing";
|
|
NEED_IP=true
|
|
}
|
|
has_virsh ||{
|
|
missing=$(( missing + 1));
|
|
_warn "virsh command is missing";
|
|
NEED_KVM=true
|
|
}
|
|
has_virt_customize || {
|
|
missing=$(( missing + 1));
|
|
_warn "virt-customize command is missing";
|
|
NEED_VIRT_CUSTOMIZE=true
|
|
}
|
|
has_wget || has_curl || {
|
|
missing=$(( missing + 1));
|
|
_warn "wget and curl commands are missing"; NEED_WGET=true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_install_dependencies(){
|
|
|
|
[ "$NEED_KVM" != "true" ] || install_kvm
|
|
[ "$NEED_VIRT_CUSTOMIZE" != "true" ] || install_virt_customize
|
|
[ "$NEED_WGET" != "true" ] || install_wget
|
|
}
|
|
|
|
|
|
case "${1:-}" in
|
|
|
|
"")
|
|
_short_help
|
|
;;
|
|
-h|--help)
|
|
_short_help
|
|
_extra_help
|
|
;;
|
|
cdeps|check-dependencies)
|
|
_check_dependencies
|
|
if [ "$missing" -gt 0 ]; then
|
|
exit 1
|
|
fi
|
|
_warn No missing dependencies
|
|
;;
|
|
ideps|install-dependencies)
|
|
_check_dependencies
|
|
_install_dependencies
|
|
;;
|
|
*)
|
|
_warn "Unknown COMMAND '$1'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
)
|
|
|
|
|
|
[ "$0" != "${BASH_SOURCE}" ] || harmony-ve-dependencies "${@}"
|
|
|