Setup libvirt and KVM
$ curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh
or if haven't curl
$ wget -O - http://retspen.github.io/libvirt-bootstrap.sh | sudo sh
#!/bin/sh -
#===============================================================================
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=81
#===============================================================================
#
# FILE: bootstrap-webvirtmgr.sh
#
# DESCRIPTION: Bootstrap webvirtmgr installation for various distributions
#
# BUGS: https://github.com/retspen/webvirtmgr-boostrap/issues
#
# COPYRIGHT: (c) 2013 by the WebVirtMgr Team
#
# LICENSE: Apache 2.0
# ORGANIZATION: WebVirtMgr (webvirtmgr.net)
# CREATED: 11/11/2013 11:00:00 EET
#===============================================================================
#--- FUNCTION ----------------------------------------------------------------
# NAME: echoerr
# DESCRIPTION: Echo errors to stderr.
#-------------------------------------------------------------------------------
echoerror() {
printf "${RC} * ERROR${EC}: $@\n" 1>&2;
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: echoinfo
# DESCRIPTION: Echo information to stdout.
#-------------------------------------------------------------------------------
echoinfo() {
printf "${GC} * INFO${EC}: %s\n" "$@";
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: echowarn
# DESCRIPTION: Echo warning informations to stdout.
#-------------------------------------------------------------------------------
echowarn() {
printf "${YC} * WARN${EC}: %s\n" "$@";
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: echodebug
# DESCRIPTION: Echo debug information to stdout.
#-------------------------------------------------------------------------------
echodebug() {
if [ $_ECHO_DEBUG -eq $BS_TRUE ]; then
printf "${BC} * DEBUG${EC}: %s\n" "$@";
fi
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __test_distro_arch
# DESCRIPTION: Echo errors to stderr.
#-------------------------------------------------------------------------------
__test_distro_arch() {
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ "$ARCH" = 32 ]; then
echoerror "32-bit Arch kernel does not support"
exit 1
fi
}
__test_distro_arch
#--- FUNCTION ----------------------------------------------------------------
# NAME: __strip_duplicates
# DESCRIPTION: Strip duplicate strings
#-------------------------------------------------------------------------------
__strip_duplicates() {
echo $@ | tr -s '[:space:]' '\n' | awk '!x[$0]++'
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __function_defined
# DESCRIPTION: Checks if a function is defined within this scripts scope
# PARAMETERS: function name
# RETURNS: 0 or 1 as in defined or not defined
#-------------------------------------------------------------------------------
__function_defined() {
FUNC_NAME=$1
if [ "$(command -v $FUNC_NAME)x" != "x" ]; then
echoinfo "Found function $FUNC_NAME"
return 0
fi
echodebug "$FUNC_NAME not found...."
return 1
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __parse_version_string
# DESCRIPTION: Parse version strings ignoring the revision.
# MAJOR.MINOR.REVISION becomes MAJOR.MINOR
#-------------------------------------------------------------------------------
__parse_version_string() {
VERSION_STRING="$1"
PARSED_VERSION=$(
echo $VERSION_STRING |
sed -e 's/^/#/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
-e 's/^#.*$//'
)
echo $PARSED_VERSION
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __sort_release_files
# DESCRIPTION: Custom sort function. Alphabetical or numerical sort is not
# enough.
#-------------------------------------------------------------------------------
__sort_release_files() {
KNOWN_RELEASE_FILES=$(echo "(arch|centos|debian|ubuntu|fedora|redhat|suse|\
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb|system|\
os)(-|_)(release|version)" | sed -r 's:[[:space:]]::g')
primary_release_files=""
secondary_release_files=""
# Sort know VS un-known files first
KVM配置TCP连接脚本 备份 libvirt-bootstrap.sh
最新推荐文章于 2024-06-08 09:57:03 发布