XO_installer/install.sh

129 lines
3.3 KiB
Bash
Raw Normal View History

2022-05-05 21:04:50 +02:00
#!/bin/sh
Black='\033[0;30m'
Red='\033[0;31m'
Green='\033[0;32m'
Yellow='\033[0;33m'
Blue='\033[0;34m'
Purple='\033[0;35m'
Cyan='\033[0;36m'
White='\033[0;37m'
NORMAL=$(tput sgr0)
2022-05-05 21:04:50 +02:00
if [ $(id -u) != 0 ] ; then
echo "Super-user (root) rights are required to install "
echo "Please run 'sudo $0' or login as root, then restart $0"
exit 1
fi
apt_install() {
if [ $? -ne 0 ]; then
echo "${Red}Cannot install $@ - Cancellation${NORMAL}"
2022-05-05 21:04:50 +02:00
exit 1
fi
}
step_1_upgrade() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 1 Update and base pakage${NORMAL}"
2022-05-05 21:04:50 +02:00
apt update
apt upgrade -y
apt install -y curl
apt install -y npm
echo "${Green}Step 1 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
step_2_node_install() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 2 Node v14 install${NORMAL}"
2022-05-05 21:04:50 +02:00
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
apt install -y nodejs
echo "${Green}Step 2 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
step_3_yarn_install() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 3 Yarn install${NORMAL}"
2022-05-05 21:04:50 +02:00
npm install --global yarn
echo "${Green}Step 3 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
step_4_packages_install() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 4 XO packages install${NORMAL}"
2022-05-05 21:04:50 +02:00
apt install -y build-essential
apt install -y redis-server
apt install -y libpng-dev
apt install -y git
apt install -y python3-minimal
apt install -y libvhdi-utils
apt install -y lvm2
apt install -y cifs-utils
echo "${Green}Step 4 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
step_5_fetching_xo_code() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 5 fetching the XO code${NORMAL}"
2022-05-05 21:04:50 +02:00
git clone -b master https://github.com/vatesfr/xen-orchestra
echo "${Green}Step 5 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
step_6_dependencies_install() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 6 Dependency install${NORMAL}"
2022-05-05 21:04:50 +02:00
cd xen-orchestra
yarn
yarn build
cd packages/xo-server
mkdir -p ~/.config/xo-server
cp sample.config.toml ~/.config/xo-server/config.toml
echo "${VERT}Step 6 completed${NORMAL}"
}
step_7_xo_running() {
echo "---------------------------------------------------------------------"
echo "${Yellow}Starting step 7 running XO${NORMAL}"
2022-05-05 21:04:50 +02:00
yarn start
echo "${Green}Step 7 completed${NORMAL}"
2022-05-05 21:04:50 +02:00
}
STEP=0
echo "${Yellow}Welcome to XO installer${NORMAL}"
echo "${Yellow}XO version : from sources${NORMAL}"
echo "${Yellow}XO folder : xen-orchestra/packages/xo-server${NORMAL}"
2022-05-05 21:04:50 +02:00
case ${STEP} in
0)
echo "${Yellow}Commence toutes les étapes de l'installation${NORMAL}"
2022-05-05 21:04:50 +02:00
step_1_upgrade
step_2_node_install
step_3_yarn_install
step_4_packages_install
step_5_fetching_xo_code
step_6_dependencies_install
step_7_xo_running
echo "Installation complete."
;;
1) step_1_upgrade
;;
2) step_2_node_install
;;
3) step_3_yarn_install
;;
4) step_4_packages_install
;;
5) step_5_fetching_xo_code
;;
6) step_6_dependencies_install
;;
7) step_7_xo_running
;;
*) echo "${Red}Sorry, I cannot select a ${STEP} step for you!${NORMAL}"
2022-05-05 21:04:50 +02:00
;;
esac
exit 0