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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3109 by torben, Wed Aug 31 09:12:33 2016 UTC revision 3195 by torben, Tue Mar 21 13:45:27 2017 UTC
# Line 5  Line 5 
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  function restartxo {  ###################################
15          killall -9 node  # Exit bash if a command fails
16          rm -f /root/forever.log  set -e
17          forever start -l /root/forever.log /root/xo-server/bin/xo-server  # also exit if a part of a pipe fails
18  }  set -o pipefail
19    
20  if [ "$1" == "restart" ] ; then  
21          restartxo  
22    
23    phymem=$(free -m|awk '/^Mem:/{print $2}')
24    swapmem=$(free -m|awk '/^Swap:/{print $2}')
25    total=$(expr $phymem + $swapmem)
26    if [ $total -le 1536 ] ; then
27            echo not enough memory: $total
28          exit          exit
29  fi  fi
30    
31  if [ "$1" == "clean" ] ; then  if [ "$1" == "clean" ] ; then
32            echo cleaning global npm packages
33            npm uninstall -g gulp
34            npm uninstall -g node-gyp
35            npm uninstall -g bcrypt
36            npm uninstall -g yarn
37    
38          echo cleaning xo-web          echo cleaning xo-web
39          rm -rf xo-web          rm -rf xo-web
40    
         echo cleaning xo-web-v4  
         rm -rf xo-web-v4  
   
41          echo cleaning xo-server          echo cleaning xo-server
42          rm -rf xo-server          rm -rf xo-server
43    
# Line 40  if [ "$1" == "clean" ] ; then Line 50  if [ "$1" == "clean" ] ; then
50          echo cleaning .cache          echo cleaning .cache
51          rm -rf .cache          rm -rf .cache
52    
         echo cleaning .forever  
         rm -rf .forever  
         rm -rf forever.log  
   
   
53          echo done          echo done
54          exit          exit
55  fi  fi
# Line 84  fi Line 89  fi
89    
90  if [ ! -x "/usr/local/bin/node" ] ; then  if [ ! -x "/usr/local/bin/node" ] ; then
91          echo "installing node.js"          echo "installing node.js"
92          n stable || exit          n lts || exit
93  fi  fi
94    
95  if [ ! -x "/usr/local/bin/gulp" ] ; then  if [ ! -x "/usr/local/bin/gulp" ] ; then
# Line 92  if [ ! -x "/usr/local/bin/gulp" ] ; then Line 97  if [ ! -x "/usr/local/bin/gulp" ] ; then
97          npm install -g gulp || exit          npm install -g gulp || exit
98  fi  fi
99    
100  if [ ! -x "/usr/local/bin/forever" ] ; then  if [ ! -x "/usr/local/bin/yarn" ] ; then
101          echo "installing forever"          echo "installing yarn"
102          npm install -g forever || exit          npm install -g yarn || exit
103  fi  fi
104    
105    
106  if [ ! -x "/usr/local/bin/node-gyp" ] ; then  if [ ! -x "/usr/local/bin/node-gyp" ] ; then
107          echo "installing node-gyp"          echo "installing node-gyp"
108          npm install -g node-gyp || exit          npm install -g node-gyp || exit
# Line 104  fi Line 110  fi
110    
111  if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then  if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
112          echo "installing bcrypt"          echo "installing bcrypt"
113          npm install -g bcrypt || exit          npm install -g --unsafe-perm bcrypt || exit
114  fi  fi
115    
116  if [ ! -d "xo-web" ] ; then  if [ ! -d "xo-web" ] ; then
# Line 115  else Line 121  else
121          cd ..          cd ..
122  fi  fi
123    
 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  
124    
125  if [ ! -d "xo-server" ] ; then  if [ ! -d "xo-server" ] ; then
126          git clone -b $BRANCH https://github.com/vatesfr/xo-server.git          git clone -b $BRANCH https://github.com/vatesfr/xo-server.git
# Line 134  fi Line 134  fi
134  # xo-server  # xo-server
135  echo "building xo-server"  echo "building xo-server"
136  cd xo-server  cd xo-server
137          npm install || exit          yarn
         npm run build || exit  
   
         #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  
138  cd ..  cd ..
139    
140    
# Line 151  cd .. Line 142  cd ..
142  #xo-web  #xo-web
143  echo "building xo-web"  echo "building xo-web"
144  cd xo-web  cd xo-web
145          #npm install --unsafe-perm || exit          yarn
         npm install || exit  
         npm run build || exit  
146  cd ..  cd ..
147    
 #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  
148    
149    dir=`dirname $0`
150    
151  if [ ! -f "/etc/xo-server/config.yaml" ] ; then  if [ ! -f "/etc/xo-server/config.yaml" ] ; then
152          if  [ ! -d "/etc/xo-server" ] ; then          if  [ ! -d "/etc/xo-server" ] ; then
153                  mkdir /etc/xo-server                  mkdir /etc/xo-server
154          fi          fi
155            copy $dir/config.yaml /etc/xo-server/config.yaml
         echo "please setup /etc/xo-server/config.yaml"  
         exit  
156  fi  fi
157    
158    echo Installing plugins
159    npm install --global xo-server-transport-email
160    npm install --global xo-server-transport-xmpp
161    npm install --global xo-server-backup-reports
162    
163    #npm install --save xo-server-usage-report
164    
165    
166  #restartxo  #restartxo
167    
168    

Legend:
Removed from v.3109  
changed lines
  Added in v.3195

  ViewVC Help
Powered by ViewVC 1.1.20