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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3194 - (show annotations) (download) (as text)
Mon Mar 20 21:54:00 2017 UTC (7 years, 2 months ago) by torben
File MIME type: application/x-sh
File size: 4276 byte(s)
add code for cleanin global npm
1 #!/bin/bash
2
3
4 # 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
20
21
22 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
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
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
50 rm -rf xo-web
51
52 # echo cleaning xo-web-v4
53 # rm -rf xo-web-v4
54
55 echo cleaning xo-server
56 rm -rf xo-server
57
58 echo cleaning .npm
59 rm -rf .npm
60
61 echo cleaning .node-gyp
62 rm -rf .node-gyp
63
64 echo cleaning .cache
65 rm -rf .cache
66
67 echo cleaning .forever
68 rm -rf .forever
69 rm -rf forever.log
70
71
72 echo done
73 exit
74 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
104 echo "installing node.js bootstrap"
105 curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit
106 chmod +x /usr/local/bin/n
107 fi
108
109 if [ ! -x "/usr/local/bin/node" ] ; then
110 echo "installing node.js"
111 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
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
135 git clone -b $BRANCH https://github.com/vatesfr/xo-web.git
136 else
137 cd xo-web
138 git pull
139 cd ..
140 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
150 git clone -b $BRANCH https://github.com/vatesfr/xo-server.git
151 else
152 cd xo-server
153 git pull
154 cd ..
155 fi
156
157
158 # xo-server
159 echo "building xo-server"
160 cd xo-server
161 npm install --unsafe-perm || exit
162 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 ..
172
173
174
175 #xo-web
176 echo "building xo-web"
177 cd xo-web
178 npm install --unsafe-perm || exit
179 #npm install || exit
180 npm run build || exit
181 cd ..
182
183 ##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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20