/[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 3182 - (hide annotations) (download) (as text)
Thu Dec 22 13:12:14 2016 UTC (7 years, 5 months ago) by torben
File MIME type: application/x-sh
File size: 4077 byte(s)
use node LTS
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     # gcc 4.7 is needed for compiling node-js modules
9 torben 2956
10 torben 3062 BRANCH=stable
11 torben 2956
12    
13 torben 3176 ###################################
14     # Exit bash if a command fails
15     set -e
16     # also exit if a part of a pipe fails
17     set -o pipefail
18    
19    
20    
21 torben 2956 function restartxo {
22     killall -9 node
23     rm -f /root/forever.log
24     forever start -l /root/forever.log /root/xo-server/bin/xo-server
25     }
26    
27     if [ "$1" == "restart" ] ; then
28     restartxo
29     exit
30     fi
31    
32 torben 3180
33     phymem=$(free -m|awk '/^Mem:/{print $2}')
34     swapmem=$(free -m|awk '/^Swap:/{print $2}')
35     total=$(expr $phymem + $swapmem)
36     if [ $total -le 1536 ] ; then
37     echo not enough memory: $total
38     exit
39     fi
40    
41 torben 2956 if [ "$1" == "clean" ] ; then
42     echo cleaning xo-web
43     rm -rf xo-web
44    
45 torben 3120 # echo cleaning xo-web-v4
46     # rm -rf xo-web-v4
47 torben 3109
48 torben 2956 echo cleaning xo-server
49     rm -rf xo-server
50    
51     echo cleaning .npm
52     rm -rf .npm
53    
54     echo cleaning .node-gyp
55     rm -rf .node-gyp
56    
57     echo cleaning .cache
58     rm -rf .cache
59    
60     echo cleaning .forever
61     rm -rf .forever
62     rm -rf forever.log
63    
64 torben 2990
65 torben 2956 echo done
66     exit
67     fi
68    
69 torben 2957
70 torben 2958 if [ ! -x "/usr/bin/curl" ] ; then
71     echo "installing curl"
72     apt-get install curl || exit
73     fi
74    
75 torben 2961 if [ ! -x "/usr/bin/gcc" ] ; then
76     echo "installing build-essential"
77     apt-get install build-essential || exit
78     fi
79 torben 2962
80 torben 2983 if [ ! -f "/usr/include/libpng12/png.h" ] ; then
81     echo "installing libpng"
82 torben 2986 apt-get install libpng12-dev || exit
83 torben 2983 fi
84    
85 torben 2962 if [ ! -x "/usr/bin/redis-server" ] ; then
86     echo "installing redis-server"
87     apt-get install redis-server || exit
88     fi
89 torben 2980
90     if [ ! -x "/usr/bin/git" ] ; then
91     echo "installing git"
92 torben 2986 apt-get install git || exit
93 torben 2980 fi
94 torben 2961
95 torben 2990
96 torben 2957 if [ ! -x "/usr/local/bin/n" ] ; then
97     echo "installing node.js bootstrap"
98     curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit
99     chmod +x /usr/local/bin/n
100     fi
101    
102     if [ ! -x "/usr/local/bin/node" ] ; then
103     echo "installing node.js"
104 torben 3182 n lts || exit
105 torben 2957 fi
106    
107 torben 2959 if [ ! -x "/usr/local/bin/gulp" ] ; then
108     echo "installing gulp"
109 torben 2986 npm install -g gulp || exit
110 torben 2959 fi
111 torben 2957
112 torben 2963 if [ ! -x "/usr/local/bin/forever" ] ; then
113     echo "installing forever"
114 torben 2986 npm install -g forever || exit
115 torben 2963 fi
116 torben 2957
117 torben 2979 if [ ! -x "/usr/local/bin/node-gyp" ] ; then
118     echo "installing node-gyp"
119 torben 2986 npm install -g node-gyp || exit
120 torben 2979 fi
121    
122 torben 2982 if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
123 torben 2981 echo "installing bcrypt"
124 torben 3180 npm install -g --unsafe-perm bcrypt || exit
125 torben 2981 fi
126 torben 2959
127 torben 2956 if [ ! -d "xo-web" ] ; then
128     git clone -b $BRANCH https://github.com/vatesfr/xo-web.git
129     else
130     cd xo-web
131     git pull
132     cd ..
133     fi
134    
135 torben 3120 #if [ ! -d "xo-web-v4" ] ; then
136     # git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4
137     # cd xo-web-v4
138     # git checkout tags/v4.16.0
139     # cd ..
140     #fi
141 torben 2956
142     if [ ! -d "xo-server" ] ; then
143     git clone -b $BRANCH https://github.com/vatesfr/xo-server.git
144     else
145     cd xo-server
146     git pull
147     cd ..
148     fi
149    
150    
151     # xo-server
152 torben 2959 echo "building xo-server"
153 torben 2956 cd xo-server
154 torben 3181 npm install --unsafe-perm || exit
155 torben 2991 npm run build || exit
156    
157     #for some reasone leveldown fails occasionally on arm/raspberry pi
158     if [ ! -d "/root/xo-server/node_modules/leveldown/build" ] ; then
159     pushd node_modules/leveldown
160     node-gyp configure || exit
161     node-gyp build || exit
162     popd
163     fi
164 torben 2956 cd ..
165    
166    
167 torben 2991
168 torben 2956 #xo-web
169 torben 2959 echo "building xo-web"
170 torben 2956 cd xo-web
171 torben 3109 #npm install --unsafe-perm || exit
172     npm install || 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    
194 torben 2990 if [ ! -f "/etc/xo-server/config.yaml" ] ; then
195     if [ ! -d "/etc/xo-server" ] ; then
196     mkdir /etc/xo-server
197     fi
198    
199 torben 2984 echo "please setup /etc/xo-server/config.yaml"
200     exit
201     fi
202    
203 torben 3176 echo Installing plugins
204     npm install --global xo-server-transport-email
205     npm install --global xo-server-transport-xmpp
206 torben 3177 npm install --global xo-server-backup-reports
207    
208 torben 3176 #npm install --save xo-server-usage-report
209    
210    
211 torben 3109 #restartxo

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20