/[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 3186 by torben, Tue Jan 3 15:16:14 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 xo-web          echo cleaning xo-web
44          rm -rf xo-web          rm -rf xo-web
45    
46    #       echo cleaning xo-web-v4
47    #       rm -rf xo-web-v4
48    
49          echo cleaning xo-server          echo cleaning xo-server
50          rm -rf xo-server          rm -rf xo-server
51    
# Line 37  if [ "$1" == "clean" ] ; then Line 61  if [ "$1" == "clean" ] ; then
61          echo cleaning .forever          echo cleaning .forever
62          rm -rf .forever          rm -rf .forever
63          rm -rf forever.log          rm -rf forever.log
64            
65    
66          echo done          echo done
67          exit          exit
68  fi  fi
69    
70    
71    if [ ! -x "/usr/bin/curl" ] ; then
72            echo "installing curl"
73            apt-get install curl || exit
74    fi
75    
76    if [ ! -x "/usr/bin/gcc" ] ; then
77            echo "installing build-essential"
78            apt-get install  build-essential || exit
79    fi
80    
81    if [ ! -f "/usr/include/libpng12/png.h" ] ; then
82            echo "installing libpng"
83            apt-get install libpng12-dev || exit
84    fi
85    
86    if [ ! -x "/usr/bin/redis-server" ] ; then
87            echo "installing redis-server"
88            apt-get install  redis-server || exit
89    fi
90    
91    if [ ! -x "/usr/bin/git" ] ; then
92            echo "installing git"
93            apt-get install git || exit
94    fi
95    
96    
97  if [ ! -x "/usr/local/bin/n" ] ; then  if [ ! -x "/usr/local/bin/n" ] ; then
98          echo "installing node.js bootstrap"          echo "installing node.js bootstrap"
99          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 102  fi
102    
103  if [ ! -x "/usr/local/bin/node" ] ; then  if [ ! -x "/usr/local/bin/node" ] ; then
104          echo "installing node.js"          echo "installing node.js"
105          n stable          n lts || exit
106  fi  fi
107    
108    if [ ! -x "/usr/local/bin/gulp" ] ; then
109            echo "installing gulp"
110            npm install -g gulp || exit
111    fi
112    
113    if [ ! -x "/usr/local/bin/forever" ] ; then
114            echo "installing forever"
115            npm install -g forever || exit
116    fi
117    
118    if [ ! -x "/usr/local/bin/node-gyp" ] ; then
119            echo "installing node-gyp"
120            npm install -g node-gyp || exit
121    fi
122    
123    if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
124            echo "installing bcrypt"
125            npm install -g --unsafe-perm bcrypt || exit
126    fi
127    
128  if [ ! -d "xo-web" ] ; then  if [ ! -d "xo-web" ] ; then
129          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 133  else
133          cd ..          cd ..
134  fi  fi
135    
136    #if [ ! -d "xo-web-v4" ] ; then
137    #       git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4
138    #       cd xo-web-v4
139    #       git checkout tags/v4.16.0
140    #       cd ..
141    #fi
142    
143  if [ ! -d "xo-server" ] ; then  if [ ! -d "xo-server" ] ; then
144          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 150  fi
150    
151    
152  # xo-server  # xo-server
153    echo "building xo-server"
154  cd xo-server  cd xo-server
155  npm install --unsafe-perm || exit          npm install --unsafe-perm || exit
156  npm run build || exit          npm run build || exit
157    
158            #for some reasone leveldown  fails occasionally on arm/raspberry pi
159            if [ ! -d "/root/xo-server/node_modules/leveldown/build" ] ; then
160                    pushd node_modules/leveldown
161                    node-gyp configure || exit
162                    node-gyp build || exit
163                    popd
164            fi
165  cd ..  cd ..
166    
167    
168    
169  #xo-web  #xo-web
170    echo "building xo-web"
171  cd xo-web  cd xo-web
172  npm install --unsafe-perm || exit          npm install --unsafe-perm || exit
173  npm run build || exit          npm run build || exit
174  cd ..  cd ..
175    
176  restartxo  ##xo-web-v4
177    #echo "building xo-web-v4"
178    #cd xo-web-v4
179    #       npm install || exit
180    #       npm run build || exit
181    #cd ..
182    
183    
184    
185    #if [ ! -f xo-web/dist/styles/main.css ] ; then
186    #       mkdir xo-web/dist/styles
187    #       mkdir xo-web/dist/images
188    #
189    #       cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css
190    #       cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png
191    #fi
192    
193    dir=`dirname $0`
194    
195    if [ ! -f "/etc/xo-server/config.yaml" ] ; then
196            if  [ ! -d "/etc/xo-server" ] ; then
197                    mkdir /etc/xo-server
198            fi
199            copy $dir/config.yaml /etc/xo-server/config.yaml
200    fi
201    
202    echo Installing plugins
203    npm install --global xo-server-transport-email
204    npm install --global xo-server-transport-xmpp
205    npm install --global xo-server-backup-reports
206    
207    #npm install --save xo-server-usage-report
208    
209    
210    #restartxo
211    
212    

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

  ViewVC Help
Powered by ViewVC 1.1.20