5 |
# |
# |
6 |
# If running on a raspberry 1(A/B) raspian/wheezy - downgrade node.js to 5.4.0 |
# 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 |
# Please note that raspian/wheezy for arm defaults to gcc 4.6 |
8 |
# gcc 4.7 is needed for compiling node-js modules |
# <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 |
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 { |
function restartxo { |
23 |
killall -9 node |
killall -9 node |
24 |
rm -f /root/forever.log |
rm -f /root/forever.log |
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 |
# echo cleaning xo-web-v4 |
47 |
rm -rf xo-web-v4 |
# rm -rf xo-web-v4 |
48 |
|
|
49 |
echo cleaning xo-server |
echo cleaning xo-server |
50 |
rm -rf xo-server |
rm -rf xo-server |
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 || exit |
n lts || exit |
106 |
fi |
fi |
107 |
|
|
108 |
if [ ! -x "/usr/local/bin/gulp" ] ; then |
if [ ! -x "/usr/local/bin/gulp" ] ; then |
122 |
|
|
123 |
if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then |
if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then |
124 |
echo "installing bcrypt" |
echo "installing bcrypt" |
125 |
npm install -g bcrypt || exit |
npm install -g --unsafe-perm bcrypt || exit |
126 |
fi |
fi |
127 |
|
|
128 |
if [ ! -d "xo-web" ] ; then |
if [ ! -d "xo-web" ] ; then |
133 |
cd .. |
cd .. |
134 |
fi |
fi |
135 |
|
|
136 |
if [ ! -d "xo-web-v4" ] ; then |
#if [ ! -d "xo-web-v4" ] ; then |
137 |
git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4 |
# git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4 |
138 |
cd xo-web-v4 |
# cd xo-web-v4 |
139 |
git checkout tags/v4.16.0 |
# git checkout tags/v4.16.0 |
140 |
cd .. |
# cd .. |
141 |
fi |
#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 |
152 |
# xo-server |
# xo-server |
153 |
echo "building xo-server" |
echo "building xo-server" |
154 |
cd xo-server |
cd xo-server |
155 |
npm install || 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 |
#for some reasone leveldown fails occasionally on arm/raspberry pi |
174 |
npm run build || exit |
npm run build || exit |
175 |
cd .. |
cd .. |
176 |
|
|
177 |
#xo-web-v4 |
##xo-web-v4 |
178 |
echo "building xo-web-v4" |
#echo "building xo-web-v4" |
179 |
cd xo-web-v4 |
#cd xo-web-v4 |
180 |
npm install || exit |
# npm install || exit |
181 |
npm run build || exit |
# npm run build || exit |
182 |
cd .. |
#cd .. |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
if [ ! -f xo-web/dist/styles/main.css ] ; then |
#if [ ! -f xo-web/dist/styles/main.css ] ; then |
187 |
mkdir xo-web/dist/styles |
# mkdir xo-web/dist/styles |
188 |
mkdir xo-web/dist/images |
# mkdir xo-web/dist/images |
189 |
|
# |
190 |
cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css |
# cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css |
191 |
cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png |
# cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png |
192 |
fi |
#fi |
193 |
|
|
194 |
|
|
195 |
if [ ! -f "/etc/xo-server/config.yaml" ] ; then |
if [ ! -f "/etc/xo-server/config.yaml" ] ; then |
201 |
exit |
exit |
202 |
fi |
fi |
203 |
|
|
204 |
|
echo Installing plugins |
205 |
|
npm install --global xo-server-transport-email |
206 |
|
npm install --global xo-server-transport-xmpp |
207 |
|
npm install --global xo-server-backup-reports |
208 |
|
|
209 |
|
#npm install --save xo-server-usage-report |
210 |
|
|
211 |
|
|
212 |
#restartxo |
#restartxo |
213 |
|
|
214 |
|
|