/[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 2957 by torben, Mon Feb 29 09:39:36 2016 UTC revision 3194 by torben, Mon Mar 20 21:54:00 2017 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3    
4  # npm install -g npm@next  # Note: this script works on debian 7/wheezy and debian 8/jessie
5    #
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    
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    
 #BRANCH=next-release  
 BRANCH=master  
20    
21    
22  function restartxo {  function restartxo {
# Line 18  if [ "$1" == "restart" ] ; then Line 30  if [ "$1" == "restart" ] ; then
30          exit          exit
31  fi  fi
32    
33    
34    phymem=$(free -m|awk '/^Mem:/{print $2}')
35    swapmem=$(free -m|awk '/^Swap:/{print $2}')
36    total=$(expr $phymem + $swapmem)
37    if [ $total -le 1536 ] ; then
38            echo not enough memory: $total
39            exit
40    fi
41    
42  if [ "$1" == "clean" ] ; then  if [ "$1" == "clean" ] ; then
43            echo cleaning global npm packages
44            npm uninstall -g gulp
45            npm uninstall -g node-gyp
46            npm uninstall -g forever
47            npm uninstall -g bcrypt
48    
49          echo cleaning xo-web          echo cleaning xo-web
50          rm -rf xo-web          rm -rf xo-web
51    
52    #       echo cleaning xo-web-v4
53    #       rm -rf xo-web-v4
54    
55          echo cleaning xo-server          echo cleaning xo-server
56          rm -rf xo-server          rm -rf xo-server
57    
# Line 37  if [ "$1" == "clean" ] ; then Line 67  if [ "$1" == "clean" ] ; then
67          echo cleaning .forever          echo cleaning .forever
68          rm -rf .forever          rm -rf .forever
69          rm -rf forever.log          rm -rf forever.log
70            
71    
72          echo done          echo done
73          exit          exit
74  fi  fi
75    
76    
77    if [ ! -x "/usr/bin/curl" ] ; then
78            echo "installing curl"
79            apt-get install curl || exit
80    fi
81    
82    if [ ! -x "/usr/bin/gcc" ] ; then
83            echo "installing build-essential"
84            apt-get install  build-essential || exit
85    fi
86    
87    if [ ! -f "/usr/include/libpng12/png.h" ] ; then
88            echo "installing libpng"
89            apt-get install libpng12-dev || exit
90    fi
91    
92    if [ ! -x "/usr/bin/redis-server" ] ; then
93            echo "installing redis-server"
94            apt-get install  redis-server || exit
95    fi
96    
97    if [ ! -x "/usr/bin/git" ] ; then
98            echo "installing git"
99            apt-get install git || exit
100    fi
101    
102    
103  if [ ! -x "/usr/local/bin/n" ] ; then  if [ ! -x "/usr/local/bin/n" ] ; then
104          echo "installing node.js bootstrap"          echo "installing node.js bootstrap"
105          curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit          curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit
# Line 52  fi Line 108  fi
108    
109  if [ ! -x "/usr/local/bin/node" ] ; then  if [ ! -x "/usr/local/bin/node" ] ; then
110          echo "installing node.js"          echo "installing node.js"
111          n stable          n lts || exit
112    fi
113    
114    if [ ! -x "/usr/local/bin/gulp" ] ; then
115            echo "installing gulp"
116            npm install -g gulp || exit
117    fi
118    
119    if [ ! -x "/usr/local/bin/forever" ] ; then
120            echo "installing forever"
121            npm install -g forever || exit
122  fi  fi
123    
124    if [ ! -x "/usr/local/bin/node-gyp" ] ; then
125            echo "installing node-gyp"
126            npm install -g node-gyp || exit
127    fi
128    
129    if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
130            echo "installing bcrypt"
131            npm install -g --unsafe-perm bcrypt || exit
132    fi
133    
134  if [ ! -d "xo-web" ] ; then  if [ ! -d "xo-web" ] ; then
135          git clone -b $BRANCH https://github.com/vatesfr/xo-web.git          git clone -b $BRANCH https://github.com/vatesfr/xo-web.git
# Line 65  else Line 139  else
139          cd ..          cd ..
140  fi  fi
141    
142    #if [ ! -d "xo-web-v4" ] ; then
143    #       git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4
144    #       cd xo-web-v4
145    #       git checkout tags/v4.16.0
146    #       cd ..
147    #fi
148    
149  if [ ! -d "xo-server" ] ; then  if [ ! -d "xo-server" ] ; then
150          git clone -b $BRANCH https://github.com/vatesfr/xo-server.git          git clone -b $BRANCH https://github.com/vatesfr/xo-server.git
# Line 76  fi Line 156  fi
156    
157    
158  # xo-server  # xo-server
159    echo "building xo-server"
160  cd xo-server  cd xo-server
161  npm install --unsafe-perm || exit          npm install --unsafe-perm || exit
162  npm run build || exit          npm run build || exit
163    
164            #for some reasone leveldown  fails occasionally on arm/raspberry pi
165            if [ ! -d "/root/xo-server/node_modules/leveldown/build" ] ; then
166                    pushd node_modules/leveldown
167                    node-gyp configure || exit
168                    node-gyp build || exit
169                    popd
170            fi
171  cd ..  cd ..
172    
173    
174    
175  #xo-web  #xo-web
176    echo "building xo-web"
177  cd xo-web  cd xo-web
178  npm install --unsafe-perm || exit          npm install --unsafe-perm || exit
179  npm run build || exit          #npm install || exit
180            npm run build || exit
181  cd ..  cd ..
182    
183  restartxo  ##xo-web-v4
184    #echo "building xo-web-v4"
185    #cd xo-web-v4
186    #       npm install || exit
187    #       npm run build || exit
188    #cd ..
189    
190    
191    
192    #if [ ! -f xo-web/dist/styles/main.css ] ; then
193    #       mkdir xo-web/dist/styles
194    #       mkdir xo-web/dist/images
195    #
196    #       cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css
197    #       cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png
198    #fi
199    
200    dir=`dirname $0`
201    
202    if [ ! -f "/etc/xo-server/config.yaml" ] ; then
203            if  [ ! -d "/etc/xo-server" ] ; then
204                    mkdir /etc/xo-server
205            fi
206            copy $dir/config.yaml /etc/xo-server/config.yaml
207    fi
208    
209    echo Installing plugins
210    npm install --global xo-server-transport-email
211    npm install --global xo-server-transport-xmpp
212    npm install --global xo-server-backup-reports
213    
214    #npm install --save xo-server-usage-report
215    
216    
217    #restartxo
218    
219    

Legend:
Removed from v.2957  
changed lines
  Added in v.3194

  ViewVC Help
Powered by ViewVC 1.1.20