--- misc/xoa-installer/xoa-installer.sh 2016/03/19 12:02:38 2984 +++ misc/xoa-installer/xoa-installer.sh 2017/01/03 15:01:59 3184 @@ -1,11 +1,22 @@ #!/bin/bash -# Note: this script works on debian 7 /wheezy -# I haven't yet managed to get it to work on deb8/jessie +# 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 -BRANCH=master +################################### +# Exit bash if a command fails +set -e +# also exit if a part of a pipe fails +set -o pipefail + function restartxo { @@ -19,10 +30,22 @@ exit fi + +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 xo-web rm -rf xo-web +# echo cleaning xo-web-v4 +# rm -rf xo-web-v4 + echo cleaning xo-server rm -rf xo-server @@ -38,7 +61,7 @@ echo cleaning .forever rm -rf .forever rm -rf forever.log - + echo done exit @@ -57,7 +80,7 @@ if [ ! -f "/usr/include/libpng12/png.h" ] ; then echo "installing libpng" - apt-get install libpng12-dev + apt-get install libpng12-dev || exit fi if [ ! -x "/usr/bin/redis-server" ] ; then @@ -67,9 +90,9 @@ if [ ! -x "/usr/bin/git" ] ; then echo "installing git" - apt-get install git + apt-get install git || exit fi - + if [ ! -x "/usr/local/bin/n" ] ; then echo "installing node.js bootstrap" @@ -79,27 +102,27 @@ if [ ! -x "/usr/local/bin/node" ] ; then echo "installing node.js" - n stable || exit + n lts || exit fi if [ ! -x "/usr/local/bin/gulp" ] ; then echo "installing gulp" - npm install -g gulp + npm install -g gulp || exit fi if [ ! -x "/usr/local/bin/forever" ] ; then echo "installing forever" - npm install -g forever + npm install -g forever || exit fi if [ ! -x "/usr/local/bin/node-gyp" ] ; then echo "installing node-gyp" - npm install -g node-gyp + npm install -g node-gyp || exit fi if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then echo "installing bcrypt" - npm install -g bcrypt + npm install -g --unsafe-perm bcrypt || exit fi if [ ! -d "xo-web" ] ; then @@ -110,6 +133,12 @@ cd .. fi +#if [ ! -d "xo-web-v4" ] ; then +# git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4 +# cd xo-web-v4 +# git checkout tags/v4.16.0 +# cd .. +#fi if [ ! -d "xo-server" ] ; then git clone -b $BRANCH https://github.com/vatesfr/xo-server.git @@ -123,23 +152,62 @@ # xo-server echo "building xo-server" cd xo-server -npm install || exit -npm run build || exit + npm install --unsafe-perm || exit + npm run build || exit + + #for some reasone leveldown fails occasionally on arm/raspberry pi + if [ ! -d "/root/xo-server/node_modules/leveldown/build" ] ; then + pushd node_modules/leveldown + node-gyp configure || exit + node-gyp build || exit + popd + fi cd .. + #xo-web echo "building xo-web" cd xo-web -npm install --unsafe-perm || exit -npm run build || exit + npm install --unsafe-perm || exit + npm run build || exit cd .. -if [ ! -f "/etc/xo-server/config.yaml" ] then +##xo-web-v4 +#echo "building xo-web-v4" +#cd xo-web-v4 +# npm install || exit +# npm run build || exit +#cd .. + + + +#if [ ! -f xo-web/dist/styles/main.css ] ; then +# mkdir xo-web/dist/styles +# mkdir xo-web/dist/images +# +# cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css +# cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png +#fi + + +if [ ! -f "/etc/xo-server/config.yaml" ] ; then + if [ ! -d "/etc/xo-server" ] ; then + mkdir /etc/xo-server + fi + echo "please setup /etc/xo-server/config.yaml" exit fi -restartxo +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