Add possibility to rollback installation. Update function/argument names to be more clear and update readme

This commit is contained in:
ronivay
2018-07-27 09:33:56 +03:00
parent badcb0c4f8
commit f08a69566d
5 changed files with 66 additions and 8 deletions

View File

@@ -15,10 +15,17 @@ Optional plugins can be installed. They are included in XO repository, but not i
Clone this repository, edit variables to suit your preferences from the xo-install.sh script and run it as root
```
basic functionality including menu:
./xo-install.sh
for non-interactive update task:
non-interactive update task (option 2):
./xo-install.sh --update
non-interactive install task (option 1):
./xo-install.sh --install
non-interactive rollback task (option 4):
./xo-install.sh --rollback
```
Tool makes some checks and offers options:
@@ -34,6 +41,9 @@ Tool makes some checks and offers options:
3. Deploy container
- Offers options to build container locally or pull from dockerhub
4. Rollback installation
- Offers option to choose which installation to use from existing ones (if more than 1)
notes:
- If you choose to install with option 2, you need to take care that required packages are already installed

View File

@@ -43,6 +43,6 @@ Vagrant.configure(2) do |config|
#
# Run automated test installation
#
config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always'
config.vm.provision :shell, path: "../../xo-install.sh", args: "--install", run: 'always'
end

View File

@@ -43,6 +43,6 @@ Vagrant.configure(2) do |config|
#
# Run automated test installation
#
config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always'
config.vm.provision :shell, path: "../../xo-install.sh", args: "--install", run: 'always'
end

View File

@@ -43,6 +43,6 @@ Vagrant.configure(2) do |config|
#
# Run automated test installation
#
config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always'
config.vm.provision :shell, path: "../../xo-install.sh", args: "--install", run: 'always'
end

View File

@@ -340,14 +340,14 @@ function UpdateXO {
} 2>$LOGFILE
function UpdateXOAutomate {
function HandleArgs {
case "$1" in
--update)
UpdateNodeYarn
UpdateXO
;;
--run-test)
--install)
if [ $OSNAME == "CentOS" ]; then
InstallDependenciesCentOS
InstallXO
@@ -358,6 +358,10 @@ function UpdateXOAutomate {
exit 0
fi
;;
--rollback)
RollBackInstallation
exit 0
;;
*)
StartUpScreen
;;
@@ -365,6 +369,44 @@ function UpdateXOAutomate {
}
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"
exit 0
fi
echo "Which installation to roll back?"
echo
local PS3="Pick a number. CTRL+C to exit: "
select INSTALLATION in "${INSTALLATIONS[@]}"; do
case $INSTALLATION in
*xen-orchestra*)
echo
echo "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"
ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web
echo
echo "Updating xo-server.service systemd configuration file location"
ln -sfn $INSTALLDIR/xo-server/xo-server.service /etc/systemd/system/xo-server.service
/bin/systemctl daemon-reload
echo
echo "Restarting xo-server..."
/bin/systemctl restart xo-server
echo
break
;;
*)
echo "Try again"
;;
esac
done
}
function CheckOS {
if [ -f /etc/centos-release ] ; then
@@ -452,6 +494,7 @@ echo "- Option 2. actually creates a new build from sources but works as an upda
echo " NodeJS and Yarn packages are updated automatically. Check AUTOUPDATE variable to disable this"
echo " Data stored in redis and /var/lib/xo-server/data will not be touched during update procedure."
echo " 3 latest installations will be preserved and older ones are deleted after successful update. Fresh installation is symlinked as active"
echo " Rollback to another installation with --rollback"
echo
echo "- To run option 2. without interactive mode (as cronjob for automated updates for example) use --update"
echo
@@ -477,7 +520,8 @@ echo
echo "1. Autoinstall"
echo "2. Update / Install without packages"
echo "3. Deploy docker container"
echo "4. Exit"
echo "4. Rollback to another existing installation"
echo "5. Exit"
echo
read -p ": " option
@@ -540,6 +584,10 @@ read -p ": " option
esac
;;
4)
RollBackInstallation
exit 0
;;
5)
exit 0
;;
*)
@@ -556,7 +604,7 @@ CheckOS
CheckSystemd
if [[ $# == "1" ]]; then
UpdateXOAutomate "$1"
HandleArgs "$1"
exit 0
else
StartUpScreen