/[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 2959 by torben, Mon Feb 29 09:49:28 2016 UTC revision 3226 by torben, Wed Apr 11 12:44:28 2018 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3    
4  # npm install -g npm@next  # Note: this script works on debian 7/wheezy and debian 8/jessie
5    #
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    # <strike>gcc 4.7</strike> is needed for compiling node-js modules
9    # 2017-01-03 gcc 4.8 is required
10    
11  #BRANCH=next-release  BRANCH=stable
 BRANCH=master  
12    
13    #Uncomment next line if you want to trick into building enterprise version
14    #export XOA_PLAN=4
15    
16  function restartxo {  ###################################
17          killall -9 node  # Exit bash if a command fails
18          rm -f /root/forever.log  set -e
19          forever start -l /root/forever.log /root/xo-server/bin/xo-server  # also exit if a part of a pipe fails
20  }  set -o pipefail
21    
22  if [ "$1" == "restart" ] ; then  
23          restartxo  
24    
25    phymem=$(free -m|awk '/^Mem:/{print $2}')
26    swapmem=$(free -m|awk '/^Swap:/{print $2}')
27    total=$(expr $phymem + $swapmem)
28    if [ $total -le 1536 ] ; then
29            echo not enough memory: $total
30          exit          exit
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    
# Line 34  if [ "$1" == "clean" ] ; then Line 52  if [ "$1" == "clean" ] ; then
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
# Line 49  if [ ! -x "/usr/bin/curl" ] ; then Line 62  if [ ! -x "/usr/bin/curl" ] ; then
62          apt-get install curl || exit          apt-get install curl || exit
63  fi  fi
64    
65    if [ ! -x "/usr/bin/gcc" ] ; then
66            echo "installing build-essential"
67            apt-get install  build-essential || exit
68    fi
69    
70    if [ ! -f "/usr/include/libpng12/png.h" ] ; then
71            echo "installing libpng"
72            apt-get install libpng12-dev || exit
73    fi
74    
75    if [ ! -x "/usr/bin/redis-server" ] ; then
76            echo "installing redis-server"
77            apt-get install  redis-server || exit
78    fi
79    
80    if [ ! -x "/usr/bin/git" ] ; then
81            echo "installing git"
82            apt-get install git || exit
83    fi
84    
85    
86  if [ ! -x "/usr/local/bin/n" ] ; then  if [ ! -x "/usr/local/bin/n" ] ; then
87          echo "installing node.js bootstrap"          echo "installing node.js bootstrap"
88          curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit          curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n || exit
# Line 57  fi Line 91  fi
91    
92  if [ ! -x "/usr/local/bin/node" ] ; then  if [ ! -x "/usr/local/bin/node" ] ; then
93          echo "installing node.js"          echo "installing node.js"
94          n stable || exit          n lts || exit
95  fi  fi
96    
97  if [ ! -x "/usr/local/bin/gulp" ] ; then  #if [ ! -x "/usr/local/bin/gulp" ] ; then
98          echo "installing gulp"  #       echo "installing gulp"
99          npm install -x gulp  #       npm install -g gulp || exit
100    #fi
101    
102    if [ ! -x "/usr/local/bin/yarn" ] ; then
103            echo "installing yarn"
104            npm install -g yarn || exit
105  fi  fi
106    
107    
108    #if [ ! -x "/usr/local/bin/node-gyp" ] ; then
109    #       echo "installing node-gyp"
110    #       npm install -g node-gyp || exit
111    #fi
112    
113  if [ ! -d "xo-web" ] ; then  #if [ ! -d "/usr/local/lib/node_modules/bcrypt" ] ; then
114          git clone -b $BRANCH https://github.com/vatesfr/xo-web.git  #       echo "installing bcrypt"
115  else  #       npm install -g --unsafe-perm bcrypt || exit
116          cd xo-web  #fi
         git pull  
         cd ..  
 fi  
117    
118    
119  if [ ! -d "xo-server" ] ; then  
120          git clone -b $BRANCH https://github.com/vatesfr/xo-server.git  if [ ! -d "xen-orchestra" ] ; then
121            git clone -b $BRANCH https://github.com/vatesfr/xen-orchestra.git
122  else  else
123          cd xo-server          cd xen-orchestra
124          git pull          git pull
125          cd ..          cd ..
126  fi  fi
127    
128    
129    
130    
131  # xo-server  # xo-server
132  echo "building xo-server"  echo "building xen-orchestra"
133  cd xo-server  cd xen-orchestra
134  npm install || exit          yarn
135  npm run build || exit          yarn build
136  cd ..  cd ..
137    
138    
 #xo-web  
 echo "building xo-web"  
 cd xo-web  
 npm install --unsafe-perm || exit  
 npm run build || exit  
 cd ..  
139    
140  restartxo  dir=`dirname $0`
141    
142    if [ ! -f "/etc/xo-server/config.yaml" ] ; then
143            if  [ ! -d "/etc/xo-server" ] ; then
144                    mkdir /etc/xo-server
145            fi
146            copy $dir/config.yaml /etc/xo-server/config.yaml
147    fi
148    
149    echo Installing plugins
150    npm install --global xo-server-transport-email
151    npm install --global xo-server-transport-xmpp
152    npm install --global xo-server-backup-reports
153    
154    #npm install --save xo-server-usage-report
155    
156    
157    #restartxo
158    
159    

Legend:
Removed from v.2959  
changed lines
  Added in v.3226

  ViewVC Help
Powered by ViewVC 1.1.20