Skip to content

Instantly share code, notes, and snippets.

@Zwilla
Last active May 21, 2020 00:09
Show Gist options
  • Save Zwilla/2cac431d746a9f39e49f27c4f053fed9 to your computer and use it in GitHub Desktop.
Save Zwilla/2cac431d746a9f39e49f27c4f053fed9 to your computer and use it in GitHub Desktop.
xen-orchestra auto install
#! /bin/sh
# Copyright Miguel Padilla (c) May 2020d
# License: WTFPL (Do What The Fuck You Want To Public License)
# FILE: /usr/local/lib/node_moules/update-github-xoa.sh
# chmod a+x /usr/local/lib/node_modules/update-github-xoa.sh
#
# https://xen-orchestra.com/docs/installation.html#xoa
#
# How to:
# * install xen xcp-ng: https://xcp-ng.org
# * Open the IP of your XCP-ng server
# * click on QUICK deploy XEN-Orchestra
# * wait until you see the new login screen of XOA
# * Stop this VM and increase the memory to build to 8 GB!
# * Start the XOA VM
# * Open your terminal and connect via ssh
# * run this lines:
#. curl https://gist.githubusercontent.com/Zwilla/2cac431d746a9f39e49f27c4f053fed9/raw/51d0cbf11f47ec9ac523f0b15e729545c41ead9a/update-github-xoa.sh > update-github-xoa.sh
# sudo chmod a+x update-github-xoa.sh
# sudo sh update-github-xoa.sh
sudo touch /opt/zwilla-xoa-auto-install.log
sudo chown xoa:xoa /opt/zwilla-xoa-auto-install.log
systemctl status xo-server >> /opt/zwilla-xoa-auto-install.log
sudo systemctl stop xo-server
# ?! Only to change/set the root password
# sudo passwd root
# su
if [ ! -d /usr/local/lib/node_modules/from-deploy ]; then
echo "Folder and Backup start"
sudo mkdir -p /usr/local/lib/node_modules/from-deploy;
sudo cp -R /usr/local/lib/node_modules/x* /usr/local/lib/node_modules/from-deploy
sudo rm -rf /usr/local/lib/node_modules/x*
sudo rm -rf /usr/local/lib/node_modules/from-deploy/*
else
echo "Folder and Backup exist"
fi;
if [ ! -d /opt/xen-orchestra ]; then
echo "First install from git, we prepare now"
sudo apt remove cmdtest -y
sudo apt-get install build-essential redis-server libpng-dev git python-minimal libvhdi-utils lvm2 cifs-utils -y
sudo apt remove yarn -y
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
yarn --version
cd /opt
git clone -b master http://github.com/vatesfr/xen-orchestra
sudo mkdir -p ~/.config/xo-server
sudo cp opt/xen-orchestra/packages/xo-server/sample.config.toml ~/.config/xo-server/config.toml
cd xen-orchestra
sudo yarn
sudo yarn build
sudo yarn update
sudo ln -sf '/opt/xen-orchestra/packages/xo-cli' '/usr/local/lib/node_modules/xoa-cli'
sudo ln -sf '/opt/xen-orchestra/packages/xo-server' '/usr/local/lib/node_modules/xo-server'
sudo ln -sf '/opt/xen-orchestra/packages/xo-web' '/usr/local/lib/node_modules/xo-web'
sudo ln -sf '/usr/local/lib/node_modules/xo-server-telemetry' '/usr/local/lib/node_modules/from-deploy/xo-server-telemetry'
sudo ln -sf '/usr/local/lib/node_modules/from-deploy/xoa-updater' '/usr/local/lib/node_modules/xoa-updater'
sudo ln -sf '/usr/local/lib/node_modules/from-deploy/xen-orchestra' '/usr/local/lib/node_modules/xen-orchestra'
sudo ln -sf '/usr/local/lib/node_modules/from-deploy/xo-server-xoa' '/usr/local/lib/node_modules/xo-server-xoa'
else
# use this -also- for updates
echo "starting git update"
cd /opt/xen-orchestra;
if git diff-index --quiet HEAD --; then
echo "No updates found";
else
sudo git checkout .
sudo git pull --ff-only
sudo yarn
sudo yarn build
sudo yarn update
echo "update from git ready";
fi;
fi;
sudo systemctl start xo-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment