--- misc/xoa-installer/xoa-installer.sh 2016/03/28 16:40:48 2990 +++ misc/xoa-installer/xoa-installer.sh 2018/01/02 12:46:58 3216 @@ -5,23 +5,38 @@ # # 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 +# gcc 4.7 is needed for compiling node-js modules +# 2017-01-03 gcc 4.8 is required -BRANCH=master +BRANCH=stable +#Uncomment next line if you want to trick into building enterprise version +#export XOA_PLAN=4 -function restartxo { - killall -9 node - rm -f /root/forever.log - forever start -l /root/forever.log /root/xo-server/bin/xo-server -} +################################### +# Exit bash if a command fails +set -e +# also exit if a part of a pipe fails +set -o pipefail -if [ "$1" == "restart" ] ; then - restartxo + + + +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 @@ -37,11 +52,6 @@ echo cleaning .cache rm -rf .cache - echo cleaning .forever - rm -rf .forever - rm -rf forever.log - - echo done exit fi @@ -81,7 +91,7 @@ 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 @@ -89,11 +99,12 @@ npm install -g gulp || exit fi -if [ ! -x "/usr/local/bin/forever" ] ; then - echo "installing forever" - npm install -g forever || exit +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 @@ -101,7 +112,7 @@ if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then echo "installing bcrypt" - npm install -g bcrypt || exit + npm install -g --unsafe-perm bcrypt || exit fi if [ ! -d "xo-web" ] ; then @@ -125,27 +136,37 @@ # xo-server echo "building xo-server" cd xo-server -npm install || exit -npm run build || exit + yarn + npm run build cd .. + #xo-web echo "building xo-web" cd xo-web -npm install --unsafe-perm || exit -npm run build || exit + yarn + npm run build cd .. + +dir=`dirname $0` + 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 + copy $dir/config.yaml /etc/xo-server/config.yaml 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