官网:

https://github.com/retspen/webvirtmgr/wiki/Setup-Host-Server

安装:

wget -O - https://retspen.github.io/libvirt-bootstrap.sh | sudo sh

脚本:

vim libvirt-bootstrap.sh
chmod libvirt-bootstrap.sh
#!/bin/sh -
#===============================================================================
# vim: softtabstop= shiftwidth= expandtab fenc=utf- spell spelllang=en cc=
#===============================================================================
#
# FILE: bootstrap-webvirtmgr.sh
#
# DESCRIPTION: Bootstrap webvirtmgr installation for various distributions
#
# BUGS: https://github.com/retspen/webvirtmgr-boostrap/issues
#
# COPYRIGHT: (c) by the WebVirtMgr Team
#
# LICENSE: Apache 2.0
# ORGANIZATION: WebVirtMgr (webvirtmgr.net)
# CREATED: // :: EET
#=============================================================================== #--- FUNCTION ----------------------------------------------------------------
# NAME: echoerr
# DESCRIPTION: Echo errors to stderr.
#-------------------------------------------------------------------------------
echoerror() {
printf "${RC} * ERROR${EC}: $@\n" >&;
} #--- 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" = ]; then
echoerror "32-bit Arch kernel does not support"
exit
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: or as in defined or not defined
#-------------------------------------------------------------------------------
__function_defined() {
FUNC_NAME=$
if [ "$(command -v $FUNC_NAME)x" != "x" ]; then
echoinfo "Found function $FUNC_NAME"
return
fi
echodebug "$FUNC_NAME not found...."
return
} #--- 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
for release_file in $(echo $@ | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do
match=$(echo $release_file | egrep -i ${KNOWN_RELEASE_FILES})
if [ "x${match}" != "x" ]; then
primary_release_files="${primary_release_files} ${release_file}"
else
secondary_release_files="${secondary_release_files} ${release_file}"
fi
done # Now let's sort by know files importance, max important goes last in the max_prio list
max_prio="redhat-release centos-release"
for entry in $max_prio; do
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g")
fi
done
# Now, least important goes last in the min_prio list
min_prio="lsb-release"
for entry in $max_prio; do
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g")
fi
done # Echo the results collapsing multiple white-space into a single white-space
echo "${primary_release_files} ${secondary_release_files}" | sed -r 's:[[:space:]]:\n:g'
} #--- FUNCTION ----------------------------------------------------------------
# NAME: __gather_linux_system_info
# DESCRIPTION: Discover Linux system information
#-------------------------------------------------------------------------------
__gather_linux_system_info() {
DISTRO_NAME=""
DISTRO_VERSION="" # Let's test if the lsb_release binary is available
rv=$(lsb_release >/dev/null >&)
if [ $? -eq ]; then
DISTRO_NAME=$(lsb_release -si)
if [ "x$(echo "$DISTRO_NAME" | grep Scientific)" != "x" ]; then
DISTRO_NAME="CentOS"
fi
if [ "x$(echo "$DISTRO_NAME" | grep RedHat)" != "x" ]; then
# Let's convert CamelCase to Camel Case
DISTRO_NAME=$(__camelcase_split "$DISTRO_NAME")
fi
if [ "${DISTRO_NAME}" = "openSUSE project" ]; then
# lsb_release -si returns "openSUSE project" on openSUSE 12.3
DISTRO_NAME="opensuse"
fi
if [ "${DISTRO_NAME}" = "SUSE LINUX" ]; then
# lsb_release -si returns "SUSE LINUX" on SLES SP3
DISTRO_NAME="suse"
fi
rv=$(lsb_release -sr)
[ "${rv}x" != "x" ] && DISTRO_VERSION=$(__parse_version_string "$rv")
elif [ -f /etc/lsb-release ]; then
# We don't have the lsb_release binary, though, we do have the file it parses
DISTRO_NAME=$(grep DISTRIB_ID /etc/lsb-release | sed -e 's/.*=//')
rv=$(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//')
[ "${rv}x" != "x" ] && DISTRO_VERSION=$(__parse_version_string "$rv")
fi if [ "x$DISTRO_NAME" != "x" ] && [ "x$DISTRO_VERSION" != "x" ]; then
# We already have the distribution name and version
return
fi for rsource in $(__sort_release_files $(
cd /etc && /bin/ls *[_-]release *[_-]version >/dev/null | env -i sort | \
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
echo redhat-release lsb-release
)); do [ -L "/etc/${rsource}" ] && continue # Don't follow symlinks
[ ! -f "/etc/${rsource}" ] && continue # Does not exist n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//')
rv=$( (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' )
[ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource
v=$(__parse_version_string "$rv")
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
redhat )
if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then
n="CentOS"
elif [ ".$(egrep 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then
n="<R>ed <H>at <E>nterprise <L>inux"
else
n="<R>ed <H>at <L>inux"
fi
;;
arch ) n="Arch Linux" ;;
centos ) n="CentOS" ;;
debian ) n="Debian" ;;
ubuntu ) n="Ubuntu" ;;
fedora ) n="Fedora" ;;
suse ) n="SUSE" ;;
system )
while read -r line; do
[ "${n}x" != "systemx" ] && break
case "$line" in
*Amazon*Linux*AMI*)
n="Amazon Linux AMI"
break
esac
done < /etc/${rsource}
;;
os )
nn=$(grep '^ID=' /etc/os-release | sed -e 's/^ID=\(.*\)$/\1/g')
rv=$(grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g')
[ "${rv}x" != "x" ] && v=$(__parse_version_string "$rv") || v=""
case $(echo ${nn} | tr '[:upper:]' '[:lower:]') in
arch )
n="Arch Linux"
v="" # Arch Linux does not provide a version.
;;
debian )
n="Debian"
if [ "${v}x" = "x" ]; then
if [ "$(cat /etc/debian_version)" = "wheezy/sid" ]; then
# I've found an EC2 wheezy image which did not tell its version
v=$(__parse_version_string "7.0")
fi
else
echowarn "Unable to parse the Debian Version"
fi
;;
* )
n=${nn}
;;
esac
;;
* ) n="${n}" ;
esac
DISTRO_NAME=$n
DISTRO_VERSION=$v
break
done
}
__gather_linux_system_info # Simplify distro name naming on functions
DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g')
DISTRO_MAJOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')"
DISTRO_MINOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).\([0-9]*\).*/\2/g')"
PREFIXED_DISTRO_MAJOR_VERSION="_${DISTRO_MAJOR_VERSION}"
if [ "${PREFIXED_DISTRO_MAJOR_VERSION}" = "_" ]; then
PREFIXED_DISTRO_MAJOR_VERSION=""
fi
PREFIXED_DISTRO_MINOR_VERSION="_${DISTRO_MINOR_VERSION}"
if [ "${PREFIXED_DISTRO_MINOR_VERSION}" = "_" ]; then
PREFIXED_DISTRO_MINOR_VERSION=""
fi #--- FUNCTION ----------------------------------------------------------------
# NAME: __check_end_of_life_versions
# DESCRIPTION: Check for end of life distribution versions
#-------------------------------------------------------------------------------
__check_end_of_life_versions() { case "${DISTRO_NAME_L}" in
debian)
# Debian versions bellow are not supported
if [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.debian.org/DebianReleases"
exit
fi
;; ubuntu)
# Ubuntu versions not supported
#
# <
# = 10.10
# = 11.04
# = 11.10
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -eq ]) || \
([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -eq ]) || \
([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -eq ]) || \
[ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.ubuntu.com/Releases"
exit
fi
;; opensuse)
# openSUSE versions not supported
#
# <= 12.1
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -eq ]) || [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://en.opensuse.org/Lifetime"
exit
fi
;; suse)
# SuSE versions not supported
#
# < SP2
SUSE_PATCHLEVEL=$(awk '/PATCHLEVEL/ {print $3}' /etc/SuSE-release )
if [ "x${SUSE_PATCHLEVEL}" = "x" ]; then
SUSE_PATCHLEVEL=""
fi
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $SUSE_PATCHLEVEL -lt ]) || [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "Versions lower than SuSE 11 SP2 are not supported."
echoerror "Please consider upgrading to the next stable"
exit
fi
;; fedora)
# Fedora lower than are no longer supported
if [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://fedoraproject.org/wiki/Releases"
exit
fi
;; centos)
# CentOS versions lower than are no longer supported
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -lt ]) || [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://wiki.centos.org/Download"
exit
fi
;; red_hat*linux)
# Red Hat (Enterprise) Linux versions lower than are no longer supported
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -lt ]) || [ $DISTRO_MAJOR_VERSION -lt ]; then
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://access.redhat.com/support/policy/updates/errata/"
exit
fi
;; *)
;;
esac
}
# Fail soon for end of life versions
__check_end_of_life_versions ##############################################################################
#
# CentOS Install Functions
#
install_centos() {
if [ $DISTRO_MAJOR_VERSION -ge ]; then
yum -y install qemu-kvm libvirt bridge-utils || return
fi
return
} install_centos_post() {
if [ -f /etc/sysconfig/libvirtd ]; then
sed -i 's/#LIBVIRTD_ARGS/LIBVIRTD_ARGS/g' /etc/sysconfig/libvirtd
else
echoerror "/etc/sysconfig/libvirtd not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/libvirtd.conf ]; then
sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
else
echoerror "/etc/libvirt/libvirtd.conf not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/qemu.conf ]; then
sed -i 's/#vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
else
echoerror "/etc/libvirt/qemu.conf not found. Exiting..."
exit
fi
return
} daemons_running_centos() {
if [ -f /etc/init.d/libvirtd ]; then
service libvirtd stop > /dev/null >&
service libvirtd start
fi
if [ -f /etc/init.d/libvirt-guests ]; then
service libvirt-guests stop > /dev/null >&
service libvirt-guests start
fi
if [ -f /usr/lib/systemd/system/libvirtd.service ]; then
systemctl stop libvirtd.service > /dev/null >&
systemctl start libvirtd.service
fi
if [ -f /usr/lib/systemd/system/libvirt-guests.service ]; then
systemctl stop libvirt-guests.service > /dev/null >&
systemctl start libvirt-guests.service
fi
return
}
#
# Ended CentOS Install Functions
#
############################################################################## ##############################################################################
#
# Fedora Install Functions
#
install_fedora() {
yum -y install kvm libvirt bridge-utils || return
return
} install_fedora_post() {
if [ -f /etc/sysconfig/libvirtd ]; then
sed -i 's/#LIBVIRTD_ARGS/LIBVIRTD_ARGS/g' /etc/sysconfig/libvirtd
else
echoerror "/etc/sysconfig/libvirtd not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/libvirtd.conf ]; then
sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
else
echoerror "/etc/libvirt/libvirtd.conf not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/qemu.conf ]; then
sed -i 's/#vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
else
echoerror "/etc/libvirt/qemu.conf not found. Exiting..."
exit
fi
return
} daemons_running_fedora() {
if [ -f /usr/lib/systemd/system/libvirtd.service ]; then
systemctl stop libvirtd.service > /dev/null >&
systemctl start libvirtd.service
fi
if [ -f /usr/lib/systemd/system/libvirt-guests.service ]; then
systemctl stop libvirt-guests.service > /dev/null >&
systemctl start libvirt-guests.service
fi
return
}
#
# Ended Fedora Install Functions
#
############################################################################## ##############################################################################
#
# Opensuse Install Functions
#
install_opensuse() {
zypper -n install -l kvm libvirt bridge-utils || return
return
} install_opensuse_post() {
if [ -f /etc/sysconfig/libvirtd ]; then
sed -i 's/#LIBVIRTD_ARGS/LIBVIRTD_ARGS/g' /etc/sysconfig/libvirtd
else
echoerror "/etc/sysconfig/libvirtd not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/libvirtd.conf ]; then
sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
else
echoerror "/etc/libvirt/libvirtd.conf not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/qemu.conf ]; then
sed -i 's/#vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
else
echoerror "/etc/libvirt/qemu.conf not found. Exiting..."
exit
fi
return
} daemons_running_opensuse() {
if [ -f /usr/lib/systemd/system/libvirtd.service ]; then
systemctl stop libvirtd.service > /dev/null >&
systemctl start libvirtd.service
fi
if [ -f /usr/lib/systemd/system/libvirt-guests.service ]; then
systemctl stop libvirt-guests.service > /dev/null >&
systemctl start libvirt-guests.service
fi
return
}
#
# Ended openSUSE Install Functions
#
############################################################################## ##############################################################################
#
# Ubuntu Install Functions
#
install_ubuntu() {
apt-get update || return
apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin || return
return
} install_ubuntu_post() {
if [ -f /etc/default/libvirt-bin ]; then
sed -i 's/libvirtd_opts="-d"/libvirtd_opts="-d -l"/g' /etc/default/libvirt-bin
else
echoerror "/etc/default/libvirt-bin not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/libvirtd.conf ]; then
sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
else
echoerror "/etc/libvirt/libvirtd.conf not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/qemu.conf ]; then
if ([ $DISTRO_MAJOR_VERSION -eq ] && [ $DISTRO_MINOR_VERSION -eq ]); then
sed -i 's/# vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
else
sed -i 's/#vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
fi
else
echoerror "/etc/libvirt/qemu.conf not found. Exiting..."
exit
fi
return
} daemons_running_ubuntu() {
if [ -f /etc/init.d/libvirt-bin ]; then
# Still in SysV init!?
service libvirt-bin stop > /dev/null >&
service libvirt-bin start
fi
return
}
#
# Ended Ubuntu Install Functions
#
############################################################################## ##############################################################################
#
# Debian Install Functions
#
install_debian() {
apt-get update || return
if [ $DISTRO_MAJOR_VERSION -ge ]; then
apt-get -y install kvm libvirt-daemon-system bridge-utils sasl2-bin || return
else
apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin || return
fi
return
} install_debian_post() {
if [ $DISTRO_MAJOR_VERSION -ge ]; then
LIBVIRTSVC=libvirtd
else
LIBVIRTSVC=libvirt-bin
fi
if [ -f /etc/default/$LIBVIRTSVC ]; then
if [ "$( grep -c '^libvirtd_opts *=' /etc/default/$LIBVIRTSVC )" -gt ]; then
if [ $( grep -c '^libvirtd_opts *=.*-l' /etc/default/$LIBVIRTSVC ) -eq ]; then
sed -i 's/^libvirtd_opts="\([^"]*\)"/libvirtd_opts="\1 -l"/g' /etc/default/$LIBVIRTSVC
fi
else
sed -i 's/^#libvirtd_opts=.*$/libvirtd_opts="-l"/g' /etc/default/$LIBVIRTSVC
fi
else
echoerror "/etc/default/$LIBVIRTSVC not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/libvirtd.conf ]; then
sed -i 's/#listen_tls/listen_tls/g' /etc/libvirt/libvirtd.conf
sed -i 's/#listen_tcp/listen_tcp/g' /etc/libvirt/libvirtd.conf
sed -i 's/#auth_tcp/auth_tcp/g' /etc/libvirt/libvirtd.conf
else
echoerror "/etc/libvirt/libvirtd.conf not found. Exiting..."
exit
fi
if [ -f /etc/libvirt/qemu.conf ]; then
sed -i 's/# vnc_listen/vnc_listen/g' /etc/libvirt/qemu.conf
else
echoerror "/etc/libvirt/qemu.conf not found. Exiting..."
exit
fi
return
} daemons_running_debian() {
if [ $DISTRO_MAJOR_VERSION -ge ]; then
LIBVIRTSVC=libvirtd
else
LIBVIRTSVC=libvirt-bin
fi
if [ -f /etc/init.d/$LIBVIRTSVC ]; then
/etc/init.d/$LIBVIRTSVC stop > /dev/null >&
/etc/init.d/$LIBVIRTSVC start
fi
return
}
#
# Ended Debian Install Functions
#
############################################################################## #=============================================================================
# INSTALLATION
#=============================================================================
# Let's get the install function
INSTALL_FUNC_NAMES="install_${DISTRO_NAME_L}" INSTALL_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $INSTALL_FUNC_NAMES); do
if __function_defined $FUNC_NAME; then
INSTALL_FUNC=$FUNC_NAME
break
fi
done
echodebug "INSTALL_FUNC=${INSTALL_FUNC}" if [ $INSTALL_FUNC = "null" ]; then
echoerror "No installation function found. Exiting..."
exit
else
echoinfo "Running ${INSTALL_FUNC}()"
$INSTALL_FUNC
if [ $? -ne ]; then
echoerror "Failed to run ${INSTALL_FUNC}()!!!"
exit
fi
fi # Let's get the post install function
POST_FUNC_NAMES="install_${DISTRO_NAME_L}_post" POST_INSTALL_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $POST_FUNC_NAMES); do
if __function_defined $FUNC_NAME; then
POST_INSTALL_FUNC=$FUNC_NAME
break
fi
done
echodebug "POST_INSTALL_FUNC=${POST_INSTALL_FUNC}" if [ $POST_INSTALL_FUNC = "null" ]; then
echoerror "No installation function found. Exiting..."
exit
else
echoinfo "Running ${POST_INSTALL_FUNC}()"
$POST_INSTALL_FUNC
if [ $? -ne ]; then
echoerror "Failed to run ${POST_INSTALL_FUNC}()!!!"
exit
fi
fi # Let's get the daemons running check function.
DAEMONS_RUNNING_FUNC_NAMES="daemons_running_${DISTRO_NAME_L}" DAEMONS_RUNNING_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $DAEMONS_RUNNING_FUNC_NAMES); do
if __function_defined $FUNC_NAME; then
DAEMONS_RUNNING_FUNC=$FUNC_NAME
break
fi
done
echodebug "DAEMONS_RUNNING_FUNC=${DAEMONS_RUNNING_FUNC}" if [ $DAEMONS_RUNNING_FUNC = "null" ]; then
echoerror "No installation function found. Exiting..."
exit
else
echoinfo "Running ${DAEMONS_RUNNING_FUNC}()"
$DAEMONS_RUNNING_FUNC
if [ $? -ne ]; then
echoerror "Failed to run ${DAEMONS_RUNNING_FUNC}()!!!"
exit
fi
fi exit

Linux通用KVM自动安装Shell脚本(兼容所有Linux发行版/CentOS/Ubuntu)的更多相关文章

  1. 实用脚本----Linux下Jdk和Tomcat自动安装shell脚本总结

    系统环境为:ubuntu 14.04 一.JDK 自动安装脚本 jdk自动安装bash shell脚本,截止今天(2014/10/15)亲测可用: sudo su #切换到root权限 mkdir / ...

  2. pgsql自动安装shell脚本整理

    前面不断在vm虚拟机上测试pgsql,发觉安装还是有些麻烦的. 所以就收集了一些 1,http://www.davidghedini.com/pg/entry/postgresql_9_5_scrip ...

  3. Linux发行版centos, ubuntu等

    公司装的是centos,centos其实就是无支持版的redhat. redhat是一个服务器的操作系统它的稳定性是比较高的,同时提供在线管理服务,服务器故障预警等,当然前提是要购买昂贵的服务. Su ...

  4. Shell脚本实现在Linux系统中自动安装JDK

    A:本脚本运行的机器,Linux B:待安装JDK的机器, Linux 首先在脚本运行的机器A上确定可以ssh无密码登录到待安装jdk的机器B上,然后就可以在A上运行本脚本: 复制代码 代码如下: $ ...

  5. shell脚本兼容linux/unix与windows/cygwin的基础(注意处理好CR, LF, CR/LF 回车 换行的问题)

    shell脚本兼容linux/unix与windows/cygwin的基础 :统一文本格式为:unix文本格式,即于LF为换行符(推荐方案) 在notepad上设置:编辑->档案格式转换-> ...

  6. Linux中使用crontab命令定时执行shell脚本或其他Linux命令

    使用crontab你可以在指定的时间执行一个shell脚本或者一系列Linux命令.例如系统管理员安排一个备份任务使其每天都运行 如何往 cron 中添加一个作业? # crontab –e0 5 * ...

  7. tomcat监控,自动重启shell脚本

    tomcat监控,自动重启shell脚本如下,取名 monitor_tomcat.sh: #!/bin/sh # func:自动监控tomcat脚本并且执行重启操作 # 获取tomcat进程ID(其中 ...

  8. 在 Linux 实例上自动安装并运行 VNC Server

    原文网址:https://help.aliyun.com/knowledge_detail/41181.html?spm=5176.8208715.110.11.4c184ae8mlC7Yy 您可以使 ...

  9. Linux学习Day6:编写Shell脚本

    Shell脚本命令的工作方式有两种: 交互式(Interactive):用户每输入一条命令就立即执行. 批处理(Batch):由用户事先编写好一个完整的Shell脚本,Shell会一次性执行脚本中诸多 ...

随机推荐

  1. yocto 离线编译

    使用yocto编译一个软件包时,一般会先在本地寻找下载好的源码包,如果不存在则根据配置从网络下载. 添加本地源码包 为了支持离线编译,添加一个包的配置文件后,需要在本地也准备好源码包. 可以先打开网络 ...

  2. 64_g6

    gsettings-desktop-schemas-devel-3.24.0-1.fc26.x..> 22-Mar-2017 20:46 19386 gsf-sharp-0.8.1-27.fc2 ...

  3. expect 实现iterm2自动加载pem登录跳板机

    #!/usr/bin/expect set timeout spawn expect { "connecting (yes/no)?" { send "yes\r&quo ...

  4. 【LOJ6201】【bzoj4939】【YNOI2016】掉进兔子洞

    一道比较简单的莫队…… 用bitset维护三个区间的交元素. #include<bits/stdc++.h> ; ; #define UI unsigned int #define rep ...

  5. Linux设备驱动--内存管理

           MMU具有物理地址和虚拟地址转换,内存访问权限保护等功能.这使得Linux操作系统能单独为每个用户进程分配独立的内存空间并且保证用户空间不能访问内核空间的地址,为操作系统虚拟内存管理模块 ...

  6. jquery获取元素索引值index()的例子

    如果参数是一组DOM元素或者jQuery对象,那么返回值就是传递的元素相对于原先集合的位置. 如果参数是一个选择器,那么返回值就是原先元素相对于选择器匹配元素中的位置.如果找不到匹配的元素,则返回-1 ...

  7. C#.Net实体代码生成工具(EntitysCodeGenerate)的使用及.NET中的ORM实现

    1 引言 目前大多数项目或产品都使用关系型数据库实现业务数据的存储,这样在开发过程中,常常有一些业务逻辑需要直接用写SQL语句实现,但这样开发的结果是:遍地布满SQL语句.这些藕合较高的SQL语句给系 ...

  8. JVM 类加载过程、初始化、主动引用、被动引用、静态初始化块执行顺序

  9. php的设计模式------工厂模式

    1.工厂模式简介 属于创建型模式.定义一个创建对象的接口,让其子类自己决定实例化哪一个工厂类,工厂模式使其创建过程延迟到子类进行主要解决的问题:接口选择的问题. 2.分类 2.1 简单工厂模式 接口: ...

  10. U43597 积木

    题目背景 小 XX 感到很无聊,从柜里翻出了小时候玩的积木. 题目描述 这套积木里共有 \(n\) 块,每块积木都是一个长方体. 小 X 想知道这些积木拼成一个积木塔(不必每一块 积木都使用). 所谓 ...