change indentation from tabs to spaces and couple other minor suggestions by shfmt
This commit is contained in:
135
xo-install.sh
135
xo-install.sh
@@ -99,8 +99,11 @@ function selfUpgrade {
|
|||||||
runcmd "cd $SCRIPT_DIR && git fetch"
|
runcmd "cd $SCRIPT_DIR && git fetch"
|
||||||
if [[ $(runcmd_stdout "cd $SCRIPT_DIR && git diff --name-only @{upstream}| grep xo-install.sh") ]]; then
|
if [[ $(runcmd_stdout "cd $SCRIPT_DIR && git diff --name-only @{upstream}| grep xo-install.sh") ]]; then
|
||||||
printinfo "Newer version of script available, attempting to self upgrade"
|
printinfo "Newer version of script available, attempting to self upgrade"
|
||||||
runcmd "cd $SCRIPT_DIR && git pull --ff-only" && \
|
runcmd "cd $SCRIPT_DIR && git pull --ff-only" &&
|
||||||
{ printok "Self upgrade done" ; exec "$SCRIPT_DIR/xo-install.sh" "$@"; } || \
|
{
|
||||||
|
printok "Self upgrade done"
|
||||||
|
exec "$SCRIPT_DIR/xo-install.sh" "$@"
|
||||||
|
} ||
|
||||||
printfail "Failed to self upgrade. Check logs for more details"
|
printfail "Failed to self upgrade. Check logs for more details"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -108,7 +111,6 @@ function selfUpgrade {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# log script version (git commit) and configuration variables to logfile
|
# log script version (git commit) and configuration variables to logfile
|
||||||
function scriptInfo {
|
function scriptInfo {
|
||||||
|
|
||||||
@@ -117,10 +119,10 @@ function scriptInfo {
|
|||||||
local SCRIPTVERSION=$(cd "$SCRIPT_DIR" 2>/dev/null && git rev-parse --short HEAD 2>/dev/null)
|
local SCRIPTVERSION=$(cd "$SCRIPT_DIR" 2>/dev/null && git rev-parse --short HEAD 2>/dev/null)
|
||||||
|
|
||||||
[ -z "$SCRIPTVERSION" ] && SCRIPTVERSION="undefined"
|
[ -z "$SCRIPTVERSION" ] && SCRIPTVERSION="undefined"
|
||||||
echo "Running script version $SCRIPTVERSION with config:" >> "$LOGFILE"
|
echo "Running script version $SCRIPTVERSION with config:" >>"$LOGFILE"
|
||||||
echo >> "$LOGFILE"
|
echo >>"$LOGFILE"
|
||||||
[ -s "$CONFIG_FILE" ] && grep -Eo '^[A-Z_]+.*' "$CONFIG_FILE" >> "$LOGFILE" || echo "No config file found" >> "$LOGFILE"
|
[ -s "$CONFIG_FILE" ] && grep -Eo '^[A-Z_]+.*' "$CONFIG_FILE" >>"$LOGFILE" || echo "No config file found" >>"$LOGFILE"
|
||||||
echo >> "$LOGFILE"
|
echo >>"$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# log actual command and it's stderr/stdout to logfile in one go
|
# log actual command and it's stderr/stdout to logfile in one go
|
||||||
@@ -200,7 +202,7 @@ function InstallDependenciesRPM {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# only install yarn repo and package if not found
|
# only install yarn repo and package if not found
|
||||||
if [[ -z $(runcmd_stdout "command -v yarn") ]] ; then
|
if [[ -z $(runcmd_stdout "command -v yarn") ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Installing yarn"
|
printprog "Installing yarn"
|
||||||
runcmd "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn"
|
runcmd "curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo && yum -y install yarn"
|
||||||
@@ -208,7 +210,7 @@ function InstallDependenciesRPM {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# only install epel-release if doesn't exist
|
# only install epel-release if doesn't exist
|
||||||
if [[ -z $(runcmd_stdout "rpm -q epel-release") ]] ; then
|
if [[ -z $(runcmd_stdout "rpm -q epel-release") ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Installing epel-repo"
|
printprog "Installing epel-repo"
|
||||||
runcmd "yum -y install epel-release"
|
runcmd "yum -y install epel-release"
|
||||||
@@ -216,7 +218,7 @@ function InstallDependenciesRPM {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# only install libvhdi-tools if vhdimount is not present
|
# only install libvhdi-tools if vhdimount is not present
|
||||||
if [[ -z $(runcmd_stdout "command -v vhdimount") ]] ; then
|
if [[ -z $(runcmd_stdout "command -v vhdimount") ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Installing libvhdi-tools from forensics repository"
|
printprog "Installing libvhdi-tools from forensics repository"
|
||||||
runcmd "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm"
|
runcmd "rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el8.rpm"
|
||||||
@@ -293,7 +295,6 @@ function InstallDependenciesDeb {
|
|||||||
printok "Installing setcap"
|
printok "Installing setcap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# only run automated node install if executable not found
|
# only run automated node install if executable not found
|
||||||
if [[ -z $(runcmd_stdout "command -v node") ]] || [[ -z $(runcmd_stdout "command -v npm") ]]; then
|
if [[ -z $(runcmd_stdout "command -v node") ]] || [[ -z $(runcmd_stdout "command -v npm") ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -402,7 +403,7 @@ function InstallAdditionalXOPlugins {
|
|||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
local ADDITIONAL_PLUGIN_REGEX="^https?:\/\/.*.git$"
|
local ADDITIONAL_PLUGIN_REGEX="^https?:\/\/.*.git$"
|
||||||
local ADDITIONAL_PLUGIN
|
local ADDITIONAL_PLUGIN
|
||||||
IFS=',' read -ra ADDITIONAL_PLUGIN <<< "$ADDITIONAL_PLUGINS"
|
IFS=',' read -ra ADDITIONAL_PLUGIN <<<"$ADDITIONAL_PLUGINS"
|
||||||
for x in "${ADDITIONAL_PLUGIN[@]}"; do
|
for x in "${ADDITIONAL_PLUGIN[@]}"; do
|
||||||
if ! [[ $x =~ $ADDITIONAL_PLUGIN_REGEX ]]; then
|
if ! [[ $x =~ $ADDITIONAL_PLUGIN_REGEX ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -447,7 +448,7 @@ function InstallXOPlugins {
|
|||||||
runcmd "find \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/\" -maxdepth 1 -mindepth 1 -not -name \"xo-server\" -not -name \"xo-web\" -not -name \"xo-server-cloud\" -exec ln -sn {} \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/\" \;"
|
runcmd "find \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/\" -maxdepth 1 -mindepth 1 -not -name \"xo-server\" -not -name \"xo-web\" -not -name \"xo-server-cloud\" -exec ln -sn {} \"$INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/\" \;"
|
||||||
else
|
else
|
||||||
local PLUGIN
|
local PLUGIN
|
||||||
IFS=',' read -ra PLUGIN <<< "$PLUGINS"
|
IFS=',' read -ra PLUGIN <<<"$PLUGINS"
|
||||||
for x in "${PLUGIN[@]}"; do
|
for x in "${PLUGIN[@]}"; do
|
||||||
if [[ $(runcmd_stdout "find $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages -type d -name '$x'") ]]; then
|
if [[ $(runcmd_stdout "find $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages -type d -name '$x'") ]]; then
|
||||||
runcmd "ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/"
|
runcmd "ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/"
|
||||||
@@ -479,7 +480,7 @@ function InstallXO {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create installation directory if doesn't exist already
|
# Create installation directory if doesn't exist already
|
||||||
if [[ ! -d "$INSTALLDIR" ]] ; then
|
if [[ ! -d "$INSTALLDIR" ]]; then
|
||||||
echo
|
echo
|
||||||
printinfo "Creating missing basedir to $INSTALLDIR"
|
printinfo "Creating missing basedir to $INSTALLDIR"
|
||||||
runcmd "mkdir -p \"$INSTALLDIR\""
|
runcmd "mkdir -p \"$INSTALLDIR\""
|
||||||
@@ -581,7 +582,10 @@ function InstallXO {
|
|||||||
if [[ $(runcmd_stdout "pgrep -f xo-server") ]]; then
|
if [[ $(runcmd_stdout "pgrep -f xo-server") ]]; then
|
||||||
echo
|
echo
|
||||||
printprog "Shutting down xo-server"
|
printprog "Shutting down xo-server"
|
||||||
runcmd "/bin/systemctl stop xo-server" || { printfail "failed to stop service, exiting..." ; exit 1; }
|
runcmd "/bin/systemctl stop xo-server" || {
|
||||||
|
printfail "failed to stop service, exiting..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
printok "Shutting down xo-server"
|
printok "Shutting down xo-server"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -590,14 +594,14 @@ function InstallXO {
|
|||||||
echo
|
echo
|
||||||
if [[ "$FORCE" != "true" ]]; then
|
if [[ "$FORCE" != "true" ]]; then
|
||||||
printinfo "Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'"
|
printinfo "Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'"
|
||||||
echo "Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" >> "$LOGFILE"
|
echo "Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" >>"$LOGFILE"
|
||||||
else
|
else
|
||||||
printinfo "Updating xen-orchestra (forced) from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'"
|
printinfo "Updating xen-orchestra (forced) from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'"
|
||||||
echo "Updating xen-orchestra (forced) from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" >> "$LOGFILE"
|
echo "Updating xen-orchestra (forced) from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" >>"$LOGFILE"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printinfo "Installing xen-orchestra from branch: $BRANCH - commit: $NEW_REPO_HASH_SHORT"
|
printinfo "Installing xen-orchestra from branch: $BRANCH - commit: $NEW_REPO_HASH_SHORT"
|
||||||
echo "Installing xen-orchestra from branch: $BRANCH - commit: $NEW_REPO_HASH_SHORT" >> "$LOGFILE"
|
echo "Installing xen-orchestra from branch: $BRANCH - commit: $NEW_REPO_HASH_SHORT" >>"$LOGFILE"
|
||||||
TASK="Installation"
|
TASK="Installation"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -636,8 +640,11 @@ function InstallXO {
|
|||||||
|
|
||||||
if [[ -n "$NODEBINARY" ]]; then
|
if [[ -n "$NODEBINARY" ]]; then
|
||||||
printprog "Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
printprog "Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
||||||
runcmd "setcap 'cap_net_bind_service=+ep' $NODEBINARY" && printok "Attempting to set cap_net_bind_service permission for $NODEBINARY" \
|
runcmd "setcap 'cap_net_bind_service=+ep' $NODEBINARY" && printok "Attempting to set cap_net_bind_service permission for $NODEBINARY" ||
|
||||||
|| { printfail "Attempting to set cap_net_bind_service permission for $NODEBINARY" ; echo " Non-privileged user might not be able to bind to <1024 port. xo-server won't start most likely" ; }
|
{
|
||||||
|
printfail "Attempting to set cap_net_bind_service permission for $NODEBINARY"
|
||||||
|
echo " Non-privileged user might not be able to bind to <1024 port. xo-server won't start most likely"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
printfail "Can't find node executable, or it's a symlink to non existing file. Not trying to setcap. xo-server won't start most likely"
|
printfail "Can't find node executable, or it's a symlink to non existing file. Not trying to setcap. xo-server won't start most likely"
|
||||||
fi
|
fi
|
||||||
@@ -660,7 +667,7 @@ function InstallXO {
|
|||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$HTTPS" == "true" ]] ; then
|
if [[ "$HTTPS" == "true" ]]; then
|
||||||
printinfo "Enabling HTTPS in xo-server configuration file"
|
printinfo "Enabling HTTPS in xo-server configuration file"
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
runcmd "sed -i \"s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
runcmd "sed -i \"s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
|
||||||
@@ -675,7 +682,6 @@ function InstallXO {
|
|||||||
runcmd "mkdir -p $CONFIGPATH/.config/xo-server"
|
runcmd "mkdir -p $CONFIGPATH/.config/xo-server"
|
||||||
runcmd "mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml"
|
runcmd "mv -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $CONFIGPATH/.config/xo-server/config.toml"
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@@ -733,7 +739,7 @@ function InstallXO {
|
|||||||
sleep 10
|
sleep 10
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
local servicestatus="$(runcmd_stdout "journalctl --since '$LOGTIME' -u xo-server | grep 'Web server listening on https\{0,1\}:\/\/.*:$PORT'")"
|
local servicestatus="$(runcmd_stdout "journalctl --since '$LOGTIME' -u xo-server | grep 'Web server listening on https\{0,1\}:\/\/.*:$PORT'")"
|
||||||
(( count++ ))
|
((count++))
|
||||||
done
|
done
|
||||||
|
|
||||||
# if it looks like service started successfully based on logs..
|
# if it looks like service started successfully based on logs..
|
||||||
@@ -746,8 +752,8 @@ function InstallXO {
|
|||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
printinfo "$TASK successful. Enabling xo-server service to start on reboot"
|
printinfo "$TASK successful. Enabling xo-server service to start on reboot"
|
||||||
echo "" >> "$LOGFILE"
|
echo "" >>"$LOGFILE"
|
||||||
echo "$TASK succesful" >> "$LOGFILE"
|
echo "$TASK succesful" >>"$LOGFILE"
|
||||||
runcmd "/bin/systemctl enable xo-server"
|
runcmd "/bin/systemctl enable xo-server"
|
||||||
echo
|
echo
|
||||||
# if service startup failed...
|
# if service startup failed...
|
||||||
@@ -755,10 +761,10 @@ function InstallXO {
|
|||||||
echo
|
echo
|
||||||
printfail "$TASK completed, but looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
printfail "$TASK completed, but looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details"
|
||||||
# shellcheck disable=SC2129
|
# shellcheck disable=SC2129
|
||||||
echo "" >> "$LOGFILE"
|
echo "" >>"$LOGFILE"
|
||||||
echo "$TASK failed" >> "$LOGFILE"
|
echo "$TASK failed" >>"$LOGFILE"
|
||||||
echo "xo-server service log:" >> "$LOGFILE"
|
echo "xo-server service log:" >>"$LOGFILE"
|
||||||
echo "" >> "$LOGFILE"
|
echo "" >>"$LOGFILE"
|
||||||
runcmd "journalctl --since '$LOGTIME' -u xo-server >> $LOGFILE"
|
runcmd "journalctl --since '$LOGTIME' -u xo-server >> $LOGFILE"
|
||||||
echo
|
echo
|
||||||
echo "Control xo-server service with systemctl for stop/start/restart etc."
|
echo "Control xo-server service with systemctl for stop/start/restart etc."
|
||||||
@@ -767,7 +773,6 @@ function InstallXO {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# run xen orchestra installation but also cleanup old installations based on value in xo-install.cfg
|
# run xen orchestra installation but also cleanup old installations based on value in xo-install.cfg
|
||||||
function UpdateXO {
|
function UpdateXO {
|
||||||
|
|
||||||
@@ -837,7 +842,7 @@ function HandleArgs {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# can't run more than one task at the same time
|
# can't run more than one task at the same time
|
||||||
if [[ "$((INSTALLARG+UPDATEARG+ROLLBACKARG))" -gt 1 ]]; then
|
if [[ "$((INSTALLARG + UPDATEARG + ROLLBACKARG))" -gt 1 ]]; then
|
||||||
echo "Define either install/update or rollback"
|
echo "Define either install/update or rollback"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -1073,40 +1078,40 @@ function CheckDiskFree {
|
|||||||
# interactive menu for different options
|
# interactive menu for different options
|
||||||
function StartUpScreen {
|
function StartUpScreen {
|
||||||
|
|
||||||
echo "-----------------------------------------"
|
echo "-----------------------------------------"
|
||||||
echo
|
echo
|
||||||
echo "Welcome to automated Xen Orchestra install"
|
echo "Welcome to automated Xen Orchestra install"
|
||||||
echo
|
echo
|
||||||
echo "Following options will be used for installation:"
|
echo "Following options will be used for installation:"
|
||||||
echo
|
echo
|
||||||
echo -e "OS: ${COLOR_WHITE}$OSNAME $OSVERSION ${COLOR_N}"
|
echo -e "OS: ${COLOR_WHITE}$OSNAME $OSVERSION ${COLOR_N}"
|
||||||
echo -e "Basedir: ${COLOR_WHITE}$INSTALLDIR ${COLOR_N}"
|
echo -e "Basedir: ${COLOR_WHITE}$INSTALLDIR ${COLOR_N}"
|
||||||
|
|
||||||
if [ "$XOUSER" ]; then
|
if [ "$XOUSER" ]; then
|
||||||
echo -e "User: ${COLOR_WHITE}$XOUSER ${COLOR_N}"
|
echo -e "User: ${COLOR_WHITE}$XOUSER ${COLOR_N}"
|
||||||
else
|
else
|
||||||
echo -e "User: ${COLOR_WHITE}root ${COLOR_N}"
|
echo -e "User: ${COLOR_WHITE}root ${COLOR_N}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Port: ${COLOR_WHITE}$PORT${COLOR_N}"
|
echo -e "Port: ${COLOR_WHITE}$PORT${COLOR_N}"
|
||||||
echo -e "HTTPS: ${COLOR_WHITE}${HTTPS}${COLOR_N}"
|
echo -e "HTTPS: ${COLOR_WHITE}${HTTPS}${COLOR_N}"
|
||||||
echo -e "Git Branch for source: ${COLOR_WHITE}$BRANCH${COLOR_N}"
|
echo -e "Git Branch for source: ${COLOR_WHITE}$BRANCH${COLOR_N}"
|
||||||
echo -e "Following plugins will be installed: ${COLOR_WHITE}$PLUGINS${COLOR_N}"
|
echo -e "Following plugins will be installed: ${COLOR_WHITE}$PLUGINS${COLOR_N}"
|
||||||
echo -e "Number of previous installations to preserve: ${COLOR_WHITE}$PRESERVE${COLOR_N}"
|
echo -e "Number of previous installations to preserve: ${COLOR_WHITE}$PRESERVE${COLOR_N}"
|
||||||
echo -e "Node.js and yarn auto update: ${COLOR_WHITE}$AUTOUPDATE${COLOR_N}"
|
echo -e "Node.js and yarn auto update: ${COLOR_WHITE}$AUTOUPDATE${COLOR_N}"
|
||||||
echo
|
echo
|
||||||
echo -e "Errorlog is stored to ${COLOR_WHITE}$LOGFILE${COLOR_N} for debug purposes"
|
echo -e "Errorlog is stored to ${COLOR_WHITE}$LOGFILE${COLOR_N} for debug purposes"
|
||||||
echo
|
echo
|
||||||
echo -e "Xen Orchestra configuration will be stored to ${COLOR_WHITE}$CONFIGPATH/.config/xo-server/config.toml${COLOR_N}, if you don't want it to be replaced with every update, set ${COLOR_WHITE}CONFIGUPDATE${COLOR_N} to false in ${COLOR_WHITE}xo-install.cfg${COLOR_N}"
|
echo -e "Xen Orchestra configuration will be stored to ${COLOR_WHITE}$CONFIGPATH/.config/xo-server/config.toml${COLOR_N}, if you don't want it to be replaced with every update, set ${COLOR_WHITE}CONFIGUPDATE${COLOR_N} to false in ${COLOR_WHITE}xo-install.cfg${COLOR_N}"
|
||||||
echo "-----------------------------------------"
|
echo "-----------------------------------------"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${COLOR_WHITE}1. Install${COLOR_N}"
|
echo -e "${COLOR_WHITE}1. Install${COLOR_N}"
|
||||||
echo -e "${COLOR_WHITE}2. Update${COLOR_N}"
|
echo -e "${COLOR_WHITE}2. Update${COLOR_N}"
|
||||||
echo -e "${COLOR_WHITE}3. Rollback${COLOR_N}"
|
echo -e "${COLOR_WHITE}3. Rollback${COLOR_N}"
|
||||||
echo -e "${COLOR_WHITE}4. Exit${COLOR_N}"
|
echo -e "${COLOR_WHITE}4. Exit${COLOR_N}"
|
||||||
echo
|
echo
|
||||||
read -r -p ": " option
|
read -r -p ": " option
|
||||||
|
|
||||||
case $option in
|
case $option in
|
||||||
1)
|
1)
|
||||||
@@ -1116,8 +1121,11 @@ read -r -p ": " option
|
|||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
echo "Stopping xo-server..."
|
echo "Stopping xo-server..."
|
||||||
runcmd "/bin/systemctl stop xo-server" \
|
runcmd "/bin/systemctl stop xo-server" ||
|
||||||
|| { printfail "failed to stop service, exiting..." ; exit 1; }
|
{
|
||||||
|
printfail "failed to stop service, exiting..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1159,7 +1167,7 @@ read -r -p ": " option
|
|||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,7 +1177,6 @@ if [[ $# == "0" ]]; then
|
|||||||
INTERACTIVE="true"
|
INTERACTIVE="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# these functions check specific requirements and are run everytime
|
# these functions check specific requirements and are run everytime
|
||||||
selfUpgrade "$@"
|
selfUpgrade "$@"
|
||||||
scriptInfo
|
scriptInfo
|
||||||
|
@@ -24,7 +24,6 @@ function OSCheck {
|
|||||||
echo "Please report any issues to this github project"
|
echo "Please report any issues to this github project"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function NetworkChoose {
|
function NetworkChoose {
|
||||||
@@ -33,16 +32,15 @@ function NetworkChoose {
|
|||||||
|
|
||||||
# get network name/uuid of all available networks configured in the pool
|
# get network name/uuid of all available networks configured in the pool
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
IFS=$'\n' read -r -d '' -a networks <<< "$(xe network-list | grep "uuid\|name-label" | cut -d':' -f2 | sed 's/^ //' | paste - -)"
|
IFS=$'\n' read -r -d '' -a networks <<<"$(xe network-list | grep "uuid\|name-label" | cut -d':' -f2 | sed 's/^ //' | paste - -)"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Which network should the VM use?"
|
echo "Which network should the VM use?"
|
||||||
echo
|
echo
|
||||||
local PS3="Pick a number. CTRL+C to exit: "
|
local PS3="Pick a number. CTRL+C to exit: "
|
||||||
select network in "${networks[@]}"
|
select network in "${networks[@]}"; do
|
||||||
do
|
|
||||||
# get only the network uuid from array which we need later on when adding vif
|
# get only the network uuid from array which we need later on when adding vif
|
||||||
read -r -a network_split <<< "$network"
|
read -r -a network_split <<<"$network"
|
||||||
networkuuid=${network_split[0]}
|
networkuuid=${network_split[0]}
|
||||||
|
|
||||||
# print a menu where to choose network from
|
# print a menu where to choose network from
|
||||||
@@ -63,7 +61,7 @@ function StorageChoose {
|
|||||||
|
|
||||||
# get storage name/uuid of all available storages with content-type=user which should match all usable storage repositories
|
# get storage name/uuid of all available storages with content-type=user which should match all usable storage repositories
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
IFS=$'\n' read -r -d '' -a storages <<< "$(xe sr-list content-type=user | grep "uuid\|name-description" | cut -d':' -f2 | sed 's/^ //' | paste - -)"
|
IFS=$'\n' read -r -d '' -a storages <<<"$(xe sr-list content-type=user | grep "uuid\|name-description" | cut -d':' -f2 | sed 's/^ //' | paste - -)"
|
||||||
|
|
||||||
# bail out if no storage repositories are found
|
# bail out if no storage repositories are found
|
||||||
if [[ ${#storages[@]} -eq 0 ]]; then
|
if [[ ${#storages[@]} -eq 0 ]]; then
|
||||||
@@ -76,10 +74,9 @@ function StorageChoose {
|
|||||||
echo "default will attempt to use pool default SR"
|
echo "default will attempt to use pool default SR"
|
||||||
echo
|
echo
|
||||||
local PS3="Pick a number. CTRL+C to exit: "
|
local PS3="Pick a number. CTRL+C to exit: "
|
||||||
select storage in "${storages[@]}" "default"
|
select storage in "${storages[@]}" "default"; do
|
||||||
do
|
|
||||||
# get only the storage repository uuid which we need later on when importing image
|
# get only the storage repository uuid which we need later on when importing image
|
||||||
read -r -a storage_split <<< "$storage"
|
read -r -a storage_split <<<"$storage"
|
||||||
storageuuid=${storage_split[0]}
|
storageuuid=${storage_split[0]}
|
||||||
|
|
||||||
# print a menu where to choose storage from
|
# print a menu where to choose storage from
|
||||||
@@ -195,7 +192,7 @@ function VMImport {
|
|||||||
echo "Waiting for VM to start and announce it got IP-address"
|
echo "Waiting for VM to start and announce it got IP-address"
|
||||||
sleep 30
|
sleep 30
|
||||||
ip=$(xe vm-param-get uuid="$uuid" param-name=networks param-key=0/ip 2>/dev/null)
|
ip=$(xe vm-param-get uuid="$uuid" param-name=networks param-key=0/ip 2>/dev/null)
|
||||||
(( count++ ))
|
((count++))
|
||||||
done
|
done
|
||||||
|
|
||||||
# network details are needed in xenstore only during first startup so remove them at this point since VM should be running
|
# network details are needed in xenstore only during first startup so remove them at this point since VM should be running
|
||||||
|
Reference in New Issue
Block a user