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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3186 - (hide annotations) (download) (as text)
Tue Jan 3 15:16:14 2017 UTC (7 years, 4 months ago) by torben
File MIME type: application/x-sh
File size: 4117 byte(s)
add config copy
1 torben 2956 #!/bin/bash
2    
3    
4 torben 2990 # Note: this script works on debian 7/wheezy and debian 8/jessie
5 torben 2989 #
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 torben 3183 # <strike>gcc 4.7</strike> is needed for compiling node-js modules
9     # 2017-01-03 gcc 4.8 is required
10 torben 2956
11 torben 3062 BRANCH=stable
12 torben 2956
13    
14 torben 3176 ###################################
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    
20    
21    
22 torben 2956 function restartxo {
23     killall -9 node
24     rm -f /root/forever.log
25     forever start -l /root/forever.log /root/xo-server/bin/xo-server
26     }
27    
28     if [ "$1" == "restart" ] ; then
29     restartxo
30     exit
31     fi
32    
33 torben 3180
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 torben 2956 if [ "$1" == "clean" ] ; then
43     echo cleaning xo-web
44     rm -rf xo-web
45    
46 torben 3120 # echo cleaning xo-web-v4
47     # rm -rf xo-web-v4
48 torben 3109
49 torben 2956 echo cleaning xo-server
50     rm -rf xo-server
51    
52     echo cleaning .npm
53     rm -rf .npm
54    
55     echo cleaning .node-gyp
56     rm -rf .node-gyp
57    
58     echo cleaning .cache
59     rm -rf .cache
60    
61     echo cleaning .forever
62     rm -rf .forever
63     rm -rf forever.log
64    
65 torben 2990
66 torben 2956 echo done
67     exit
68     fi
69    
70 torben 2957
71 torben 2958 if [ ! -x "/usr/bin/curl" ] ; then
72     echo "installing curl"
73     apt-get install curl || exit
74     fi
75    
76 torben 2961 if [ ! -x "/usr/bin/gcc" ] ; then
77     echo "installing build-essential"
78     apt-get install build-essential || exit
79     fi
80 torben 2962
81 torben 2983 if [ ! -f "/usr/include/libpng12/png.h" ] ; then
82     echo "installing libpng"
83 torben 2986 apt-get install libpng12-dev || exit
84 torben 2983 fi
85    
86 torben 2962 if [ ! -x "/usr/bin/redis-server" ] ; then
87     echo "installing redis-server"
88     apt-get install redis-server || exit
89     fi
90 torben 2980
91     if [ ! -x "/usr/bin/git" ] ; then
92     echo "installing git"
93 torben 2986 apt-get install git || exit
94 torben 2980 fi
95 torben 2961
96 torben 2990
97 torben 2957 if [ ! -x "/usr/local/bin/n" ] ; then
98     echo "installing node.js bootstrap"
99     curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit
100     chmod +x /usr/local/bin/n
101     fi
102    
103     if [ ! -x "/usr/local/bin/node" ] ; then
104     echo "installing node.js"
105 torben 3182 n lts || exit
106 torben 2957 fi
107    
108 torben 2959 if [ ! -x "/usr/local/bin/gulp" ] ; then
109     echo "installing gulp"
110 torben 2986 npm install -g gulp || exit
111 torben 2959 fi
112 torben 2957
113 torben 2963 if [ ! -x "/usr/local/bin/forever" ] ; then
114     echo "installing forever"
115 torben 2986 npm install -g forever || exit
116 torben 2963 fi
117 torben 2957
118 torben 2979 if [ ! -x "/usr/local/bin/node-gyp" ] ; then
119     echo "installing node-gyp"
120 torben 2986 npm install -g node-gyp || exit
121 torben 2979 fi
122    
123 torben 2982 if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
124 torben 2981 echo "installing bcrypt"
125 torben 3180 npm install -g --unsafe-perm bcrypt || exit
126 torben 2981 fi
127 torben 2959
128 torben 2956 if [ ! -d "xo-web" ] ; then
129     git clone -b $BRANCH https://github.com/vatesfr/xo-web.git
130     else
131     cd xo-web
132     git pull
133     cd ..
134     fi
135    
136 torben 3120 #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 torben 2956
143     if [ ! -d "xo-server" ] ; then
144     git clone -b $BRANCH https://github.com/vatesfr/xo-server.git
145     else
146     cd xo-server
147     git pull
148     cd ..
149     fi
150    
151    
152     # xo-server
153 torben 2959 echo "building xo-server"
154 torben 2956 cd xo-server
155 torben 3181 npm install --unsafe-perm || exit
156 torben 2991 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 torben 2956 cd ..
166    
167    
168 torben 2991
169 torben 2956 #xo-web
170 torben 2959 echo "building xo-web"
171 torben 2956 cd xo-web
172 torben 3184 npm install --unsafe-perm || exit
173 torben 2991 npm run build || exit
174 torben 2956 cd ..
175    
176 torben 3120 ##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 torben 2991
183 torben 3109
184    
185 torben 3120 #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 torben 3109
193 torben 3186 dir=`dirname $0`
194 torben 3109
195 torben 2990 if [ ! -f "/etc/xo-server/config.yaml" ] ; then
196     if [ ! -d "/etc/xo-server" ] ; then
197     mkdir /etc/xo-server
198     fi
199 torben 3186 copy $dir/config.yaml /etc/xo-server/config.yaml
200 torben 2984 fi
201    
202 torben 3176 echo Installing plugins
203     npm install --global xo-server-transport-email
204     npm install --global xo-server-transport-xmpp
205 torben 3177 npm install --global xo-server-backup-reports
206    
207 torben 3176 #npm install --save xo-server-usage-report
208    
209    
210 torben 3109 #restartxo

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20