10 |
|
|
11 |
BRANCH=stable |
BRANCH=stable |
12 |
|
|
13 |
|
#Uncomment next line if you want to trick into building enterprise version |
14 |
|
#export XOA_PLAN=4 |
15 |
|
|
16 |
################################### |
################################### |
17 |
# Exit bash if a command fails |
# Exit bash if a command fails |
21 |
|
|
22 |
|
|
23 |
|
|
|
function restartxo { |
|
|
killall -9 node |
|
|
rm -f /root/forever.log |
|
|
forever start -l /root/forever.log /root/xo-server/bin/xo-server |
|
|
} |
|
|
|
|
|
if [ "$1" == "restart" ] ; then |
|
|
restartxo |
|
|
exit |
|
|
fi |
|
|
|
|
24 |
|
|
25 |
phymem=$(free -m|awk '/^Mem:/{print $2}') |
phymem=$(free -m|awk '/^Mem:/{print $2}') |
26 |
swapmem=$(free -m|awk '/^Swap:/{print $2}') |
swapmem=$(free -m|awk '/^Swap:/{print $2}') |
31 |
fi |
fi |
32 |
|
|
33 |
if [ "$1" == "clean" ] ; then |
if [ "$1" == "clean" ] ; then |
34 |
|
echo cleaning global npm packages |
35 |
|
npm uninstall -g gulp |
36 |
|
npm uninstall -g node-gyp |
37 |
|
npm uninstall -g bcrypt |
38 |
|
npm uninstall -g yarn |
39 |
|
|
40 |
echo cleaning xo-web |
echo cleaning xo-web |
41 |
rm -rf xo-web |
rm -rf xo-web |
42 |
|
|
|
# echo cleaning xo-web-v4 |
|
|
# rm -rf xo-web-v4 |
|
|
|
|
43 |
echo cleaning xo-server |
echo cleaning xo-server |
44 |
rm -rf xo-server |
rm -rf xo-server |
45 |
|
|
52 |
echo cleaning .cache |
echo cleaning .cache |
53 |
rm -rf .cache |
rm -rf .cache |
54 |
|
|
|
echo cleaning .forever |
|
|
rm -rf .forever |
|
|
rm -rf forever.log |
|
|
|
|
|
|
|
55 |
echo done |
echo done |
56 |
exit |
exit |
57 |
fi |
fi |
99 |
npm install -g gulp || exit |
npm install -g gulp || exit |
100 |
fi |
fi |
101 |
|
|
102 |
if [ ! -x "/usr/local/bin/forever" ] ; then |
if [ ! -x "/usr/local/bin/yarn" ] ; then |
103 |
echo "installing forever" |
echo "installing yarn" |
104 |
npm install -g forever || exit |
npm install -g yarn || exit |
105 |
fi |
fi |
106 |
|
|
107 |
|
|
108 |
if [ ! -x "/usr/local/bin/node-gyp" ] ; then |
if [ ! -x "/usr/local/bin/node-gyp" ] ; then |
109 |
echo "installing node-gyp" |
echo "installing node-gyp" |
110 |
npm install -g node-gyp || exit |
npm install -g node-gyp || exit |
123 |
cd .. |
cd .. |
124 |
fi |
fi |
125 |
|
|
|
#if [ ! -d "xo-web-v4" ] ; then |
|
|
# git clone -b $BRANCH https://github.com/vatesfr/xo-web.git xo-web-v4 |
|
|
# cd xo-web-v4 |
|
|
# git checkout tags/v4.16.0 |
|
|
# cd .. |
|
|
#fi |
|
126 |
|
|
127 |
if [ ! -d "xo-server" ] ; then |
if [ ! -d "xo-server" ] ; then |
128 |
git clone -b $BRANCH https://github.com/vatesfr/xo-server.git |
git clone -b $BRANCH https://github.com/vatesfr/xo-server.git |
136 |
# xo-server |
# xo-server |
137 |
echo "building xo-server" |
echo "building xo-server" |
138 |
cd xo-server |
cd xo-server |
139 |
npm install --unsafe-perm || exit |
yarn |
140 |
npm run build || exit |
npm run build |
|
|
|
|
#for some reasone leveldown fails occasionally on arm/raspberry pi |
|
|
if [ ! -d "/root/xo-server/node_modules/leveldown/build" ] ; then |
|
|
pushd node_modules/leveldown |
|
|
node-gyp configure || exit |
|
|
node-gyp build || exit |
|
|
popd |
|
|
fi |
|
141 |
cd .. |
cd .. |
142 |
|
|
143 |
|
|
145 |
#xo-web |
#xo-web |
146 |
echo "building xo-web" |
echo "building xo-web" |
147 |
cd xo-web |
cd xo-web |
148 |
npm install --unsafe-perm || exit |
yarn |
149 |
npm run build || exit |
npm run build |
150 |
cd .. |
cd .. |
151 |
|
|
|
##xo-web-v4 |
|
|
#echo "building xo-web-v4" |
|
|
#cd xo-web-v4 |
|
|
# npm install || exit |
|
|
# npm run build || exit |
|
|
#cd .. |
|
|
|
|
|
|
|
|
|
|
|
#if [ ! -f xo-web/dist/styles/main.css ] ; then |
|
|
# mkdir xo-web/dist/styles |
|
|
# mkdir xo-web/dist/images |
|
|
# |
|
|
# cp xo-web-v4/dist/styles/main.css xo-web/dist/styles/main.css |
|
|
# cp xo-web-v4/dist/images/logo_small.png xo-web/dist/images/logo_small.png |
|
|
#fi |
|
152 |
|
|
153 |
|
dir=`dirname $0` |
154 |
|
|
155 |
if [ ! -f "/etc/xo-server/config.yaml" ] ; then |
if [ ! -f "/etc/xo-server/config.yaml" ] ; then |
156 |
if [ ! -d "/etc/xo-server" ] ; then |
if [ ! -d "/etc/xo-server" ] ; then |
157 |
mkdir /etc/xo-server |
mkdir /etc/xo-server |
158 |
fi |
fi |
159 |
|
copy $dir/config.yaml /etc/xo-server/config.yaml |
|
echo "please setup /etc/xo-server/config.yaml" |
|
|
exit |
|
160 |
fi |
fi |
161 |
|
|
162 |
echo Installing plugins |
echo Installing plugins |