diff --git a/xo-install.sh b/xo-install.sh index 58b24c2..e3aa3ea 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -28,6 +28,16 @@ PRESERVE=${PRESERVE:-"3"} # Set path where new source is cloned/pulled XO_SRC_DIR="$INSTALLDIR/xo-src/xen-orchestra" +# Set variables for stdout print +COLOR_N='\e[0m' +COLOR_GREEN='\e[1;32m' +COLOR_RED='\e[1;31m' +COLOR_BLUE='\e[1;34m' +OK="[${COLOR_GREEN}ok${COLOR_N}]" +FAIL="[${COLOR_RED}fail${COLOR_N}]" +INFO="[${COLOR_BLUE}info${COLOR_N}]" +PROGRESS="[${COLOR_BLUE}...${COLOR_N}]" + # Protocol to use for webserver. If both of the X.509 certificate files exist, # then assume that we want to enable HTTPS for the server. if [[ -e $PATH_TO_HTTPS_CERT ]] && [[ -e $PATH_TO_HTTPS_KEY ]]; then @@ -41,7 +51,7 @@ function CheckUser { # Make sure the script is ran as root if [[ ! "$(id -u)" == "0" ]]; then - echo "This script needs to be ran as root" + echo -e "${FAIL} This script needs to be ran as root" exit 0 fi @@ -49,10 +59,10 @@ function CheckUser { function ErrorHandling { - echo "Something went wrong, exiting. Check $LOGFILE for more details and use rollback feature if needed" + echo -e "${FAIL} Something went wrong, exiting. Check $LOGFILE for more details and use rollback feature if needed" if [[ -d $INSTALLDIR/xo-builds/xen-orchestra-$TIME ]]; then - echo "Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation." + echo -e "${FAIL} Removing $INSTALLDIR/xo-builds/xen-orchestra-$TIME because of failed installation." rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME fi } @@ -68,53 +78,53 @@ function InstallDependenciesCentOS { # only run automated node install if package not found if [[ -z $(rpm -qa | grep ^node) ]]; then echo - echo -n "Installing node.js..." + echo -ne "${PROGRESS} Installing node.js" curl -s -L https://rpm.nodesource.com/setup_8.x | bash - >/dev/null - echo "done" + echo -e "\r${OK} Installing node.js" fi # only install yarn repo and package if not found if [[ -z $(rpm -qa | grep yarn) ]]; then echo - echo -n "Installing yarn..." + echo -ne "${PROGRESS} Installing yarn" curl -s -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo >/dev/null && \ yum -y install yarn >/dev/null - echo "done" + echo -e "\r${OK} Installing yarn" fi # only install epel-release if doesn't exist if [[ -z $(rpm -qa | grep epel-release) ]]; then echo - echo -n "Installing epel-repo..." + echo -ne "${PROGRESS} Installing epel-repo" yum -y install epel-release >/dev/null - echo "done" + echo -e "\r${OK} Installing epel-repo" fi # only install libvhdi-tools if vhdimount is not present if [[ -z $(which vhdimount) ]]; then echo - echo -n "Installing libvhdi-tools from forensics repository..." + echo -ne "${PROGRESS} Installing libvhdi-tools from forensics repository" rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm >/dev/null sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/cert-forensics-tools.repo yum --enablerepo=forensics install -y libvhdi-tools >/dev/null - echo "done" + echo -e "\r${OK} Installing libvhdi-tools from forensics repository" fi # install echo - echo -n "Installing build dependencies, redis server, python, git, nfs-utils..." + echo -ne "${PROGRESS} Installing build dependencies, redis server, python, git, nfs-utils" yum -y install gcc gcc-c++ make openssl-devel redis libpng-devel python git nfs-utils >/dev/null - echo "done" + echo -e "\r${OK} Installing build dependencies, redis server, python, git, nfs-utils" echo - echo -n "Enabling and starting redis service..." + echo -ne "${PROGRESS} Enabling and starting redis service" /bin/systemctl enable redis >/dev/null && /bin/systemctl start redis >/dev/null - echo "done" + echo -e "\r${OK} Enabling and starting redis service" echo - echo -n "Enabling and starting rpcbind service..." + echo -ne "${PROGRESS} Enabling and starting rpcbind service" /bin/systemctl enable rpcbind >/dev/null && /bin/systemctl start rpcbind >/dev/null - echo "done" + echo -e "\r${OK} Enabling and starting rpcbind service" } 2>$LOGFILE @@ -127,69 +137,69 @@ function InstallDependenciesDebian { # Install necessary dependencies for XO build echo - echo -n "Running apt-get update..." + echo -ne "${PROGRESS} Running apt-get update" apt-get update >/dev/null - echo "done" + echo -e "\r${OK} Running apt-get update" # Install apt-transport-https and ca-certificates because of yarn https repo url echo - echo -n "Installing apt-transport-https and ca-certificates packages to support https repos..." + echo -ne "${PROGRESS} Installing apt-transport-https and ca-certificates packages to support https repos" apt-get install -y apt-transport-https ca-certificates >/dev/null - echo "done" + echo -e "\r${OK} Installing apt-transport-https and ca-certificates packages to support https repos" # install curl for later tasks if missing if [[ -z $(which curl) ]]; then echo - echo -n "Installing curl..." + echo -ne "${PROGRESS} Installing curl" apt-get install -y curl >/dev/null - echo "done" + echo -e "\r${OK} Installing curl" fi # install setcap for non-root port binding if missing if [[ -z $(which setcap) ]]; then echo - echo -n "Installing setcap..." + echo -ne "${PROGRESS} Installing setcap" apt-get install -y libcap2-bin >/dev/null - echo "done" + echo -e "\r${OK} Installing setcap" fi # only install yarn repo and package if not found if [[ -z $(dpkg -l | grep yarn) ]]; then echo - echo -n "Installing yarn..." + echo -ne "${PROGRESS} Installing yarn" curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - >/dev/null echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list >/dev/null apt-get update >/dev/null apt-get install -y yarn >/dev/null - echo "done" + echo -e "\r${OK} Installing yarn" fi # only run automated node install if package not found if [[ -z $(dpkg -l | grep node) ]] || [[ -z $(which npm) ]]; then echo - echo -n "Installing node.js..." + echo -ne "${PROGRESS} Installing node.js" curl -sL https://deb.nodesource.com/setup_8.x | bash - >/dev/null apt-get install -y nodejs >/dev/null - echo "done" + echo -e "\r${OK} Installing node.js" fi # install packages echo - echo -n "Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common..." + echo -ne "${PROGRESS} Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common" apt-get install -y build-essential redis-server libpng-dev git python-minimal libvhdi-utils lvm2 nfs-common >/dev/null - echo "done" + echo -e "\r${OK} Installing build dependencies, redis server, python, git, libvhdi-utils, lvm2, nfs-common" echo - echo -n "Enabling and starting redis service..." + echo -ne "${PROGRESS} Enabling and starting redis service" /bin/systemctl enable redis-server >/dev/null && /bin/systemctl start redis-server >/dev/null - echo "done" + echo -e "\r${OK} Enabling and starting redis service" echo - echo -n "Enabling and starting rpcbind service..." + echo -ne "${PROGRESS} Enabling and starting rpcbind service" /bin/systemctl enable rpcbind >/dev/null && /bin/systemctl start rpcbind >/dev/null - echo "done" + echo -e "\r${OK} Enabling and starting rpcbind service" } 2>$LOGFILE @@ -199,12 +209,14 @@ function UpdateNodeYarn { if [ $OSNAME == "CentOS" ]; then echo - echo "Checking updates for nodejs and yarn" + echo -ne "${PROGRESS} Checking updates for nodejs and yarn" yum update -y nodejs yarn > /dev/null + echo -e "\r${OK} Checking updates for nodejs and yarn" else echo - echo "Checking updates for nodejs and yarn" + echo -ne "${PROGRESS} Checking updates for nodejs and yarn" apt-get install -y --only-upgrade nodejs yarn > /dev/null + echo -e "\r${OK} Checking updates for nodejs and yarn" fi fi @@ -220,18 +232,20 @@ function InstallXOPlugins { if [[ "$PLUGINS" == "all" ]]; then echo - echo "Installing all available plugins as defined in PLUGINS variable" + echo -ne "${PROGRESS} Installing all available plugins as defined in PLUGINS variable" 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/" \; + echo -e "\r${OK} Installing all available plugins as defined in PLUGINS variable" else echo - echo "Installing plugins defined in PLUGINS variable" - echo + echo -ne "${PROGRESS} Installing plugins defined in PLUGINS variable" local PLUGINSARRAY=($(echo "$PLUGINS" | tr ',' ' ')) for x in "${PLUGINSARRAY[@]}"; do if [[ $(find $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages -type d -name "$x") ]]; then ln -sn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/$x $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/node_modules/ + echo -e "\r${OK} Installing plugins defined in PLUGINS variable" else - echo "No $x plugin found from xen-orchestra packages, skipping" + echo -e "\r${FAIL} Installing plugins defined in PLUGINS variable" + echo -e " ${INFO} No $x plugin found from xen-orchestra packages, skipping" continue fi done @@ -240,7 +254,7 @@ function InstallXOPlugins { cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build >/dev/null else echo - echo "No plugins to install" + echo -e "${INFO} No plugins to install" fi } 2>$LOGFILE @@ -258,27 +272,29 @@ function InstallXO { if [ $XOUSER ]; then if [[ -z $(getent passwd $XOUSER) ]]; then echo - echo "Creating missing $XOUSER user" + echo -ne "${PROGRESS} Creating missing $XOUSER user" useradd -s /sbin/nologin $XOUSER - echo + echo -e "\r${OK} Creating missing $XOUSER user" sleep 2 fi fi # Create installation directory if doesn't exist already if [[ ! -d "$INSTALLDIR" ]] ; then - echo "Creating missing basedir to $INSTALLDIR" + echo -ne "${PROGRESS} Creating missing basedir to $INSTALLDIR" mkdir -p "$INSTALLDIR" + echo -e "\r${OK} Creating missing basedir to $INSTALLDIR" fi # Create missing xo-builds directory if doesn't exist already if [[ ! -d "$INSTALLDIR/xo-builds" ]]; then - echo "Creating missing xo-builds directory to $INSTALLDIR/xo-builds" + echo -ne "${PROGRESS} Creating missing xo-builds directory to $INSTALLDIR/xo-builds" mkdir "$INSTALLDIR/xo-builds" + echo -e "\r${OK} Creating missing xo-builds directory to $INSTALLDIR/xo-builds" fi echo - echo "Fetching Xen Orchestra source code ..." + echo -e "${INFO} Fetching Xen Orchestra source code" echo if [[ ! -d "$XO_SRC_DIR" ]]; then mkdir -p "$XO_SRC_DIR" @@ -291,7 +307,7 @@ function InstallXO { # Deploy the latest xen-orchestra source to the new install directory. echo - echo "Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" + echo -ne "${INFO} Creating install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" rm -rf "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" cp -r "$XO_SRC_DIR" "$INSTALLDIR/xo-builds/xen-orchestra-$TIME" @@ -300,22 +316,19 @@ function InstallXO { TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) echo - echo "Checking out latest tagged release '$TAG'" + echo -e "${INFO} Checking out latest tagged release '$TAG'" git checkout $TAG 2> /dev/null # Suppress the detached-head message. cd $(dirname $0) elif [[ "$BRANCH" != "master" ]]; then echo - echo "Checking out source code from branch '$BRANCH'" + echo -e "${INFO} Checking out source code from branch '$BRANCH'" cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME git checkout $BRANCH cd $(dirname $0) fi - echo - echo "done" - # Check if the new repo is any different from the currently-installed # one. If not, then skip the build and delete the repo we just cloned. @@ -343,8 +356,8 @@ function InstallXO { # proceed with the build. if [[ "$NEW_REPO_HASH" == "$OLD_REPO_HASH" ]]; then echo - echo "No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build." - echo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" + echo -e "${INFO} No changes to xen-orchestra since previous install. Skipping xo-server and xo-web build." + echo -e "${INFO} Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME return 0 fi @@ -353,36 +366,36 @@ function InstallXO { # sure there's no already-running xo-server process. if [[ $(ps aux | grep xo-server | grep -v grep) ]]; then echo - echo -n "Shutting down xo-server..." - /bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; } - echo "done" + echo -ne "${PROGRESS} Shutting down xo-server" + /bin/systemctl stop xo-server || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; } + echo -e "\r${OK} Shutting down xo-server" fi # If this isn't a fresh install, then list the upgrade the user is making. if [[ ! -z "$OLD_REPO_HASH" ]]; then echo - echo "Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" + echo -e "${INFO}Updating xen-orchestra from '$OLD_REPO_HASH_SHORT' to '$NEW_REPO_HASH_SHORT'" fi echo - echo "xo-server and xo-web build quite a while. Grab a cup of coffee and lay back" + echo -e "${INFO} xo-server and xo-web build quite a while. Grab a cup of coffee and lay back" echo - echo -n "Running installation..." + echo -ne "${PROGRESS} Running installation" cd $INSTALLDIR/xo-builds/xen-orchestra-$TIME && yarn >/dev/null && yarn build >/dev/null - echo "done" + echo -e "\r${OK} Running installation" # Install plugins InstallXOPlugins echo - echo "Fixing binary path in systemd service configuration file" + echo -e "${INFO} Fixing binary path in systemd service configuration file" sed -i "s#ExecStart=.*#ExecStart=$INSTALLDIR\/xo-server\/bin\/xo-server#" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service echo - echo "Adding WorkingDirectory parameter to systemd service configuration file" + echo -e "${INFO} Adding WorkingDirectory parameter to systemd service configuration file" sed -i "/ExecStart=.*/a WorkingDirectory=$INSTALLDIR/xo-server" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service if [ $XOUSER ]; then - echo "Adding user to systemd config" + echo -e "${INFO} Adding user to systemd config" sed -i "/SyslogIdentifier=.*/a User=$XOUSER" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service if [ "$PORT" -le "1024" ]; then @@ -392,16 +405,16 @@ function InstallXO { fi if [[ ! -z $NODEBINARY ]]; then - echo -n "Attempting to set cap_net_bind_service permission for $NODEBINARY..." + echo -ne "${INFO} Attempting to set cap_net_bind_service permission for $NODEBINARY" setcap 'cap_net_bind_service=+ep' $NODEBINARY >/dev/null \ - && echo "Success" || echo "Failed. Non-privileged user might not be able to bind to <1024 port. xo-server won't start most likely" + && echo -e "\r${OK} Attempting to set cap_net_bind_service permission for $NODEBINARY" || { echo -e "\r${FAIL} 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 - echo "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" + echo -e "${FAIL} 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 fi - echo "Fixing relative path to xo-web installation in xo-server configuration file" + echo -e ${INFO} "Fixing relative path to xo-web installation in xo-server configuration file" # temporarily look for .yaml file first, if not found then assume that new .toml format exists if [[ -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml ]]; then @@ -409,20 +422,20 @@ function InstallXO { sleep 2 if [[ $PORT != "80" ]]; then - echo "Changing port in xo-server configuration file" + echo -e "${INFO} Changing port in xo-server configuration file" sed -i "s/port: 80/port: $PORT/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml sleep 2 fi if $HTTPS ; then - echo "Enabling HTTPS in xo-server configuration file" + echo -e "${INFO} Enabling HTTPS in xo-server configuration file" sed -i "s%# cert: '.\/certificate.pem'% cert: '$PATH_TO_HTTPS_CERT'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml sed -i "s%# key: '.\/key.pem'% key: '$PATH_TO_HTTPS_KEY'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml sed -i "s/#redirectToHttps/redirectToHttps/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml sleep 2 fi - echo "Activating modified configuration file" + echo -e "${INFO} Activating modified configuration file" mv $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.yaml $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/.xo-server.yaml else @@ -430,28 +443,28 @@ function InstallXO { sleep 2 if [[ $PORT != "80" ]]; then - echo "Changing port in xo-server configuration file" + echo -e "${INFO} Changing port in xo-server configuration file" sed -i "s/port = 80/port = $PORT/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml sleep 2 fi if $HTTPS ; then - echo "Enabling HTTPS in xo-server configuration file" + echo -e "${INFO} Enabling HTTPS in xo-server configuration file" sed -i "s%# cert = '.\/certificate.pem'%cert = '$PATH_TO_HTTPS_CERT'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml sed -i "s%# key = '.\/key.pem'%key = '$PATH_TO_HTTPS_KEY'%" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml sed -i "s/# redirectToHttps/redirectToHttps/" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml sleep 2 fi - echo "Activating modified configuration file" + echo -e "${INFO} Activating modified configuration file" mv $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/.xo-server.toml fi echo - echo "Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server" + echo -e "${INFO} Symlinking fresh xo-server install/update to $INSTALLDIR/xo-server" ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server $INSTALLDIR/xo-server sleep 2 - echo "Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web" + echo -e "${INFO} Symlinking fresh xo-web install/update to $INSTALLDIR/xo-web" ln -sfn $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-web $INSTALLDIR/xo-web if [ $XOUSER ]; then @@ -470,17 +483,17 @@ function InstallXO { fi echo - echo "Replacing systemd service configuration file" + echo -e "${INFO} Replacing systemd service configuration file" /bin/cp -f $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service sleep 2 - echo "Reloading systemd configuration" + echo -e "${INFO} Reloading systemd configuration" echo /bin/systemctl daemon-reload sleep 2 echo - echo "Starting xo-server..." + echo -e "${INFO} Starting xo-server..." /bin/systemctl start xo-server >/dev/null # no need to exit/trap on errors anymore @@ -489,21 +502,21 @@ function InstallXO { timeout 60 bash <<-"EOF" while [[ -z $(journalctl -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT") ]]; do - echo "waiting for port to be open" + echo " waiting for port to be open" sleep 10 done EOF if [[ $(journalctl -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT") ]]; then echo - echo "WebUI started in port $PORT. Make sure you have firewall rules in place to allow access." - echo "Default username: admin@admin.net password: admin" + echo -e " ${COLOR_GREEN}WebUI started in port $PORT. Make sure you have firewall rules in place to allow access.${COLOR_N}" + echo -e " ${COLOR_GREEN}Default username: admin@admin.net password: admin${COLOR_N}" echo - echo "Installation successful. Enabling xo-server to start on reboot" + echo -e "${INFO} Installation successful. Enabling xo-server to start on reboot" /bin/systemctl enable xo-server > /dev/null else echo - echo "Looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details" + echo -e "${FAIL} Looks like there was a problem when starting xo-server/reading journalctl. Please see logs for more details" journalctl -u xo-server -n 50 >> $LOGFILE exit 1 fi @@ -519,11 +532,11 @@ function UpdateXO { # remove old builds. leave as many as defined in PRESERVE variable echo - echo -n "Removing old installations (leaving $PRESERVE latest)..." + echo -ne "${PROGRESS} Removing old installations. Leaving $PRESERVE latest" find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xen-orchestra*" -printf "%T@ %p\n" | sort -n | cut -d' ' -f2- | head -n -$PRESERVE | xargs -r rm -r - echo "done" + echo -e "\r${OK} Removing old installations. Leaving $PRESERVE latest" else - echo "PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup" + echo -e "${INFO} PRESERVE variable is set to 0. This needs to be at least 1. Not doing a cleanup" fi } 2>$LOGFILE @@ -562,7 +575,7 @@ function RollBackInstallation { INSTALLATIONS=($(find $INSTALLDIR/xo-builds/ -maxdepth 1 -type d -name "xen-orchestra-*")) if [[ $(echo ${#INSTALLATIONS[@]}) -le 1 ]]; then - echo "Only one installation exists, nothing to change" + echo -e "${INFO} Only one installation exists, nothing to change" exit 0 fi @@ -573,22 +586,22 @@ function RollBackInstallation { case $INSTALLATION in *xen-orchestra*) echo - echo "Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server" + echo -e "${INFO} Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server" ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server - echo "Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web" + echo -e "${INFO} Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web" ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web echo - echo "Replacing xo.server.service systemd configuration file" + echo -e "${INFO} Replacing xo.server.service systemd configuration file" /bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service /bin/systemctl daemon-reload echo - echo "Restarting xo-server..." + echo -e "${INFO} Restarting xo-server..." /bin/systemctl restart xo-server echo break ;; *) - echo "Try again" + echo -e "${FAIL} Try again" ;; esac done @@ -601,21 +614,21 @@ function CheckOS { OSVERSION=$(grep -Eo "[0-9]" /etc/centos-release | head -1) OSNAME="CentOS" if [[ ! $OSVERSION == "7" ]]; then - echo "Only CentOS 7 supported" + echo -e "${FAIL} Only CentOS 7 supported" exit 0 fi elif [[ -f /etc/os-release ]]; then OSVERSION=$(grep ^VERSION_ID /etc/os-release | cut -d'=' -f2 | grep -Eo "[0-9]{1,2}" | head -1) OSNAME=$(grep ^NAME /etc/os-release | cut -d'=' -f2 | sed 's/"//g' | awk '{print $1}') if [[ $OSNAME == "Debian" ]] && [[ ! $OSVERSION =~ ^(8|9)$ ]]; then - echo "Only Debian 8/9 supported" + echo -e "${FAIL} Only Debian 8/9 supported" exit 0 elif [[ $OSNAME == "Ubuntu" ]] && [[ ! $OSVERSION =~ ^(16|18)$ ]]; then - echo "Only Ubuntu 16/18 supported" + echo -e "${FAIL} Only Ubuntu 16/18 supported" exit 0 fi else - echo "Only CentOS 7 / Ubuntu 16/18 and Debian 8/9 supported" + echo -e "${FAIL} Only CentOS 7 / Ubuntu 16/18 and Debian 8/9 supported" exit 0 fi @@ -624,7 +637,7 @@ function CheckOS { function CheckSystemd { if [ -z $(which systemctl) ]; then - echo "This tool is designed to work with systemd enabled systems only" + echo -e "${FAIL} This tool is designed to work with systemd enabled systems only" exit 0 fi } @@ -633,7 +646,7 @@ function CheckDocker { if [ -z $(which docker) ]; then echo - echo "Docker needs to be installed for this to work" + echo -e "${FAIL} Docker needs to be installed for this to work" exit 0 fi @@ -645,12 +658,12 @@ function CheckCertificate { local KEY="$(openssl rsa -modulus -noout -in "$PATH_TO_HTTPS_KEY" | openssl md5)" if [[ "$CERT" != "$KEY" ]]; then echo - echo "$PATH_TO_HTTPS_CERT:" - echo "$CERT" - echo "$PATH_TO_HTTPS_KEY:" - echo "$KEY" + echo -e "${INFO} $PATH_TO_HTTPS_CERT:" + echo -e "${INFO} $CERT" + echo -e "${INFO} $PATH_TO_HTTPS_KEY:" + echo -e "${INFO} $KEY" echo - echo "MD5 of your TLS key and certificate don't match. Please check files and try again." + echo -e "{$FAIL} MD5 of your TLS key and certificate dont match. Please check files and try again." exit 1 fi fi @@ -663,11 +676,11 @@ function PullDockerImage { docker pull ronivay/xen-orchestra echo echo - echo "Image pulled. Run container:" - echo "docker run -itd -p 80:80 ronivay/xen-orchestra" + echo -e "${INFO} Image pulled. Run container:" + echo " docker run -itd -p 80:80 ronivay/xen-orchestra" echo - echo "If you want to persist xen-orchestra and redis data, use volume flags like:" - echo "docker run -itd -p 80:80 -v /path/to/data/xo-server:/var/lib/xo-server -v /path/to/data/redis:/var/lib/redis ronivay/xen-orchestra" + echo -e "${INFO} If you want to persist xen-orchestra and redis data, use volume flags like:" + echo " docker run -itd -p 80:80 -v /path/to/data/xo-server:/var/lib/xo-server -v /path/to/data/redis:/var/lib/redis ronivay/xen-orchestra" } 2>$LOGFILE @@ -726,7 +739,7 @@ read -p ": " option case $answer in y) echo "Stopping xo-server..." - /bin/systemctl stop xo-server || { echo "failed to stop service, exiting..." ; exit 1; } + /bin/systemctl stop xo-server || { echo -e "${FAIL} failed to stop service, exiting..." ; exit 1; } ;; n) exit 0