/[projects]/misc/xoa-installer/xoa-installer.sh
ViewVC logotype

Diff of /misc/xoa-installer/xoa-installer.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2984 by torben, Sat Mar 19 12:02:38 2016 UTC revision 3195 by torben, Tue Mar 21 13:45:27 2017 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3    
4  # Note: this script works on debian 7 /wheezy  # Note: this script works on debian 7/wheezy and debian 8/jessie
5  # I haven't yet managed to get it to work on deb8/jessie  #
6    # If running on a raspberry 1(A/B) raspian/wheezy - downgrade node.js to 5.4.0
7    # Please note that raspian/wheezy for arm defaults to gcc 4.6
8    # <strike>gcc 4.7</strike> is needed for compiling node-js modules
9    # 2017-01-03 gcc 4.8 is required
10    
11    BRANCH=stable
12    
 BRANCH=master  
13    
14    ###################################
15    # Exit bash if a command fails
16    set -e
17    # also exit if a part of a pipe fails
18    set -o pipefail
19    
 function restartxo {  
         killall -9 node  
         rm -f /root/forever.log  
         forever start -l /root/forever.log /root/xo-server/bin/xo-server  
 }  
20    
21  if [ "$1" == "restart" ] ; then  
22          restartxo  
23    phymem=$(free -m|awk '/^Mem:/{print $2}')
24    swapmem=$(free -m|awk '/^Swap:/{print $2}')
25    total=$(expr $phymem + $swapmem)
26    if [ $total -le 1536 ] ; then
27            echo not enough memory: $total
28          exit          exit
29  fi  fi
30    
31  if [ "$1" == "clean" ] ; then  if [ "$1" == "clean" ] ; then
32            echo cleaning global npm packages
33            npm uninstall -g gulp
34            npm uninstall -g node-gyp
35            npm uninstall -g bcrypt
36            npm uninstall -g yarn
37    
38          echo cleaning xo-web          echo cleaning xo-web
39          rm -rf xo-web          rm -rf xo-web
40    
# Line 35  if [ "$1" == "clean" ] ; then Line 50  if [ "$1" == "clean" ] ; then
50          echo cleaning .cache          echo cleaning .cache
51          rm -rf .cache          rm -rf .cache
52    
         echo cleaning .forever  
         rm -rf .forever  
         rm -rf forever.log  
           
   
53          echo done          echo done
54          exit          exit
55  fi  fi
# Line 57  fi Line 67  fi
67    
68  if [ ! -f "/usr/include/libpng12/png.h" ] ; then  if [ ! -f "/usr/include/libpng12/png.h" ] ; then
69          echo "installing libpng"          echo "installing libpng"
70          apt-get install libpng12-dev          apt-get install libpng12-dev || exit
71  fi  fi
72    
73  if [ ! -x "/usr/bin/redis-server" ] ; then  if [ ! -x "/usr/bin/redis-server" ] ; then
# Line 67  fi Line 77  fi
77    
78  if [ ! -x "/usr/bin/git" ] ; then  if [ ! -x "/usr/bin/git" ] ; then
79          echo "installing git"          echo "installing git"
80          apt-get install git          apt-get install git || exit
81  fi  fi
82            
83    
84  if [ ! -x "/usr/local/bin/n" ] ; then  if [ ! -x "/usr/local/bin/n" ] ; then
85          echo "installing node.js bootstrap"          echo "installing node.js bootstrap"
# Line 79  fi Line 89  fi
89    
90  if [ ! -x "/usr/local/bin/node" ] ; then  if [ ! -x "/usr/local/bin/node" ] ; then
91          echo "installing node.js"          echo "installing node.js"
92          n stable || exit          n lts || exit
93  fi  fi
94    
95  if [ ! -x "/usr/local/bin/gulp" ] ; then  if [ ! -x "/usr/local/bin/gulp" ] ; then
96          echo "installing gulp"          echo "installing gulp"
97          npm install -g gulp          npm install -g gulp || exit
98  fi  fi
99    
100  if [ ! -x "/usr/local/bin/forever" ] ; then  if [ ! -x "/usr/local/bin/yarn" ] ; then
101          echo "installing forever"          echo "installing yarn"
102          npm install -g forever          npm install -g yarn || exit
103  fi  fi
104    
105    
106  if [ ! -x "/usr/local/bin/node-gyp" ] ; then  if [ ! -x "/usr/local/bin/node-gyp" ] ; then
107          echo "installing node-gyp"          echo "installing node-gyp"
108          npm install -g node-gyp          npm install -g node-gyp || exit
109  fi  fi
110    
111  if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then  if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
112          echo "installing bcrypt"          echo "installing bcrypt"
113          npm install -g bcrypt          npm install -g --unsafe-perm bcrypt || exit
114  fi  fi
115    
116  if [ ! -d "xo-web" ] ; then  if [ ! -d "xo-web" ] ; then
# Line 123  fi Line 134  fi
134  # xo-server  # xo-server
135  echo "building xo-server"  echo "building xo-server"
136  cd xo-server  cd xo-server
137  npm install || exit          yarn
 npm run build || exit  
138  cd ..  cd ..
139    
140    
141    
142  #xo-web  #xo-web
143  echo "building xo-web"  echo "building xo-web"
144  cd xo-web  cd xo-web
145  npm install --unsafe-perm || exit          yarn
 npm run build || exit  
146  cd ..  cd ..
147    
148  if [ ! -f "/etc/xo-server/config.yaml" ] then  
149          echo "please setup /etc/xo-server/config.yaml"  dir=`dirname $0`
150          exit  
151    if [ ! -f "/etc/xo-server/config.yaml" ] ; then
152            if  [ ! -d "/etc/xo-server" ] ; then
153                    mkdir /etc/xo-server
154            fi
155            copy $dir/config.yaml /etc/xo-server/config.yaml
156  fi  fi
157    
158  restartxo  echo Installing plugins
159    npm install --global xo-server-transport-email
160    npm install --global xo-server-transport-xmpp
161    npm install --global xo-server-backup-reports
162    
163    #npm install --save xo-server-usage-report
164    
165    
166    #restartxo
167    
168    

Legend:
Removed from v.2984  
changed lines
  Added in v.3195

  ViewVC Help
Powered by ViewVC 1.1.20