#!/bin/bash # Note: this script works on debian 7/wheezy and debian 8/jessie # # If running on a raspberry 1(A/B) raspian/wheezy - downgrade node.js to 5.4.0 # Please note that raspian/wheezy for arm defaults to gcc 4.6 # gcc 4.7 is needed for compiling node-js modules # 2017-01-03 gcc 4.8 is required BRANCH=stable #Uncomment next line if you want to trick into building enterprise version #export XOA_PLAN=4 ################################### # Exit bash if a command fails set -e # also exit if a part of a pipe fails set -o pipefail phymem=$(free -m|awk '/^Mem:/{print $2}') swapmem=$(free -m|awk '/^Swap:/{print $2}') total=$(expr $phymem + $swapmem) if [ $total -le 1536 ] ; then echo not enough memory: $total exit fi if [ "$1" == "clean" ] ; then echo cleaning global npm packages npm uninstall -g gulp npm uninstall -g node-gyp npm uninstall -g bcrypt npm uninstall -g yarn echo cleaning xo-web rm -rf xo-web echo cleaning xo-server rm -rf xo-server echo cleaning .npm rm -rf .npm echo cleaning .node-gyp rm -rf .node-gyp echo cleaning .cache rm -rf .cache echo done exit fi if [ ! -x "/usr/bin/curl" ] ; then echo "installing curl" apt-get install curl || exit fi if [ ! -x "/usr/bin/gcc" ] ; then echo "installing build-essential" apt-get install build-essential || exit fi if [ ! -f "/usr/include/libpng12/png.h" ] ; then echo "installing libpng" apt-get install libpng12-dev || exit fi if [ ! -x "/usr/bin/redis-server" ] ; then echo "installing redis-server" apt-get install redis-server || exit fi if [ ! -x "/usr/bin/git" ] ; then echo "installing git" apt-get install git || exit fi if [ ! -x "/usr/local/bin/n" ] ; then echo "installing node.js bootstrap" curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit chmod +x /usr/local/bin/n fi if [ ! -x "/usr/local/bin/node" ] ; then echo "installing node.js" n lts || exit fi #if [ ! -x "/usr/local/bin/gulp" ] ; then # echo "installing gulp" # npm install -g gulp || exit #fi if [ ! -x "/usr/local/bin/yarn" ] ; then echo "installing yarn" npm install -g yarn || exit fi #if [ ! -x "/usr/local/bin/node-gyp" ] ; then # echo "installing node-gyp" # npm install -g node-gyp || exit #fi #if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then # echo "installing bcrypt" # npm install -g --unsafe-perm bcrypt || exit #fi if [ ! -d "xen-orchestra" ] ; then git clone -b $BRANCH https://github.com/vatesfr/xen-orchestra.git else cd xen-orchestra git pull cd .. fi # xo-server echo "building xen-orchestra" cd xen-orchestra yarn yarn build cd .. dir=`dirname $0` if [ ! -f "/etc/xo-server/config.yaml" ] ; then if [ ! -d "/etc/xo-server" ] ; then mkdir /etc/xo-server fi copy $dir/config.yaml /etc/xo-server/config.yaml fi echo Installing plugins npm install --global xo-server-transport-email npm install --global xo-server-transport-xmpp npm install --global xo-server-backup-reports #npm install --save xo-server-usage-report #restartxo