/[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 3194 - (hide 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 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 torben 3194 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 torben 2956 echo cleaning xo-web
50     rm -rf xo-web
51    
52 torben 3120 # echo cleaning xo-web-v4
53     # rm -rf xo-web-v4
54 torben 3109
55 torben 2956 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 torben 2990
72 torben 2956 echo done
73     exit
74     fi
75    
76 torben 2957
77 torben 2958 if [ ! -x "/usr/bin/curl" ] ; then
78     echo "installing curl"
79     apt-get install curl || exit
80     fi
81    
82 torben 2961 if [ ! -x "/usr/bin/gcc" ] ; then
83     echo "installing build-essential"
84     apt-get install build-essential || exit
85     fi
86 torben 2962
87 torben 2983 if [ ! -f "/usr/include/libpng12/png.h" ] ; then
88     echo "installing libpng"
89 torben 2986 apt-get install libpng12-dev || exit
90 torben 2983 fi
91    
92 torben 2962 if [ ! -x "/usr/bin/redis-server" ] ; then
93     echo "installing redis-server"
94     apt-get install redis-server || exit
95     fi
96 torben 2980
97     if [ ! -x "/usr/bin/git" ] ; then
98     echo "installing git"
99 torben 2986 apt-get install git || exit
100 torben 2980 fi
101 torben 2961
102 torben 2990
103 torben 2957 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 torben 3182 n lts || exit
112 torben 2957 fi
113    
114 torben 2959 if [ ! -x "/usr/local/bin/gulp" ] ; then
115     echo "installing gulp"
116 torben 2986 npm install -g gulp || exit
117 torben 2959 fi
118 torben 2957
119 torben 2963 if [ ! -x "/usr/local/bin/forever" ] ; then
120     echo "installing forever"
121 torben 2986 npm install -g forever || exit
122 torben 2963 fi
123 torben 2957
124 torben 2979 if [ ! -x "/usr/local/bin/node-gyp" ] ; then
125     echo "installing node-gyp"
126 torben 2986 npm install -g node-gyp || exit
127 torben 2979 fi
128    
129 torben 2982 if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
130 torben 2981 echo "installing bcrypt"
131 torben 3180 npm install -g --unsafe-perm bcrypt || exit
132 torben 2981 fi
133 torben 2959
134 torben 2956 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 torben 3120 #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 torben 2956
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 torben 2959 echo "building xo-server"
160 torben 2956 cd xo-server
161 torben 3181 npm install --unsafe-perm || exit
162 torben 2991 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 torben 2956 cd ..
172    
173    
174 torben 2991
175 torben 2956 #xo-web
176 torben 2959 echo "building xo-web"
177 torben 2956 cd xo-web
178 torben 3188 npm install --unsafe-perm || exit
179     #npm install || exit
180 torben 2991 npm run build || exit
181 torben 2956 cd ..
182    
183 torben 3120 ##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 torben 2991
190 torben 3109
191    
192 torben 3120 #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 torben 3109
200 torben 3186 dir=`dirname $0`
201 torben 3109
202 torben 2990 if [ ! -f "/etc/xo-server/config.yaml" ] ; then
203     if [ ! -d "/etc/xo-server" ] ; then
204     mkdir /etc/xo-server
205     fi
206 torben 3186 copy $dir/config.yaml /etc/xo-server/config.yaml
207 torben 2984 fi
208    
209 torben 3176 echo Installing plugins
210     npm install --global xo-server-transport-email
211     npm install --global xo-server-transport-xmpp
212 torben 3177 npm install --global xo-server-backup-reports
213    
214 torben 3176 #npm install --save xo-server-usage-report
215    
216    
217 torben 3109 #restartxo

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20