You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
5.6 KiB

  1. #!/bin/bash
  2. set -eux # -x for verbose logging to juju debug-log
  3. ##
  4. ## Options (changeable thanks to ``/etc/charm/openerp.conf``)
  5. ##
  6. OPENERP_PASSWORD=${OPENERP_PASSWORD:-openerp_password}
  7. ## 0k git remote path
  8. GIT_0K_BASE=${GIT_0K_BASE:-"git.0k.io:/var/git"}
  9. ## 0k git remote options
  10. GIT_0K_CLONE_OPTIONS=${GIT_0K_CLONE_OPTIONS:-""}
  11. ## 0k git-sub setup options
  12. GIT_0K_SUB_CLONE_OPTIONS=${GIT_0K_SUB_CLONE_OPTIONS:-""}
  13. ## 0k git default checkout reference (for 0k-oe root package)
  14. GIT_0K_CHECKOUT_REF=${GIT_0K_CHECKOUT_REF:-"8.0/0k/dev/master"}
  15. release=$(lsb_release -c -s)
  16. ##
  17. ## Code
  18. ##
  19. apt-get install sudo libxml2-dev libxslt-dev libpq-dev libyaml-dev \
  20. zlib1g-dev libfreetype6-dev \
  21. libjpeg-dev libmysqlclient-dev -y --force-yes
  22. set +eux
  23. source /srv/virtualenv/default/bin/activate
  24. set -eux
  25. ## install deps for PIL compilations
  26. ## from http://www.sandersnewmedia.com/why/2012/04/16/installing-pil-virtualenv-ubuntu-1204
  27. if ! [ -e "/usr/lib/libjpeg.so" ]; then
  28. if [ "$release" == "trusty" ]; then
  29. ## for some reason /etc/apt/sources.list can be WITHOUT deb-src lines
  30. apt-cache policy python-imaging | tail -n 1 | \
  31. while read code url distrib arch type; do
  32. echo deb-src $url $(echo "$distrib" | tr "/" " ");
  33. done >> /etc/apt/sources.list &&
  34. apt-get update
  35. fi
  36. if ! [ -d "/usr/include/freetype2/freetype" ]; then
  37. (cd /usr/include/freetype2 &&
  38. ln -sf . freetype)
  39. fi
  40. apt-get build-dep python-imaging -y --force-yes &&
  41. ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/ &&
  42. ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/ &&
  43. ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
  44. fi
  45. ## Installing PIL with our archive is safer.
  46. #pip install pil
  47. (
  48. cd /tmp &&
  49. scp "$GIT_0K_BASE"/archives/PIL-1.1.7.tar.gz . &&
  50. tar xvzf PIL-1.1.7.tar.gz &&
  51. cd PIL-1.1.7 &&
  52. python setup.py install
  53. )
  54. pip install lxml genshi==0.6 pyparsing==1.5.7 psycopg2 pyyaml reportlab mako \
  55. pywebdav==0.9.4 feedparser caldav pytz pydot \
  56. python-dateutil==1.5 cherrypy formencode==1.2.2 \
  57. babel simplejson==2.0.9 python-openid mysql-python vatnumber \
  58. mock unittest2 fudge docutils jinja2 gdata sact.epoch \
  59. shyaml psutil
  60. ## Install pychart... from our repo as :
  61. ## download link in PyPi is dead,
  62. ## and gna.org was down recently
  63. (
  64. scp "$GIT_0K_BASE/archives/PyChart-1.39.tar.gz" /tmp &&
  65. cd /tmp && tar xvzf PyChart*.tar.gz &&
  66. cd PyChart* &&
  67. python setup.py install
  68. )
  69. ## Install OOOP... from our git repo as:
  70. ## we have some bug correction and custom features
  71. if ! [ -d "/opt/apps/ooop" ]; then
  72. (
  73. cd /opt/apps &&
  74. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/ooop.git" &&
  75. cd /opt/apps/ooop &&
  76. git checkout 0k/prod/master &&
  77. ## beurk
  78. ln -sf /opt/apps/ooop/ooop.py /srv/virtualenv/default/lib/python2.7/ooop.py
  79. )
  80. fi
  81. ## Install aerolib... from our git repo as:
  82. if ! [ -d "/opt/apps/aeroolib" ]; then
  83. (
  84. cd /opt/apps &&
  85. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/aeroolib.git" &&
  86. cd /opt/apps/aeroolib &&
  87. git checkout master &&
  88. ## beurk
  89. ln -sf /opt/apps/aeroolib/aeroolib/aeroolib /srv/virtualenv/default/lib/python2.7/aeroolib
  90. )
  91. fi
  92. ##
  93. ## Install 0k-oe
  94. ##
  95. (
  96. cd /opt/apps &&
  97. git sub clone $GIT_0K_CLONE_OPTIONS $GIT_0K_SUB_CLONE_OPTIONS -b "$GIT_0K_CHECKOUT_REF" \
  98. "$GIT_0K_BASE"/0k/0k-oe
  99. )
  100. adduser --system --home=/var/lib/openerp --group openerp
  101. ## XXXvlab: warning password in charm !!
  102. cp -i etc/openerp-server.conf /etc/
  103. sed -ri "s/%%PASSWORD%%/$OPENERP_PASSWORD/g" /etc/openerp-server.conf
  104. cp -i etc/init.d/openerp-server /etc/init.d/
  105. chown openerp /etc/openerp-server.conf
  106. chmod 600 /etc/openerp-server.conf
  107. chown openerp /etc/init.d/openerp-server
  108. update-rc.d openerp-server defaults
  109. mkdir /var/log/openerp
  110. touch /var/log/openerp/openerp-server.log
  111. chown openerp /var/log/openerp -R
  112. cp -i etc/default/openerp-server /etc/default/openerp-server
  113. ## Install add-ons
  114. ## make a better way for installing add-ons
  115. #addons_path=/opt/apps/openobject-addons/0k
  116. #if ! [ -d "$addons_path" ]; then
  117. # mkdir -p $addons_path
  118. # for addons in $(/var/git/list-addons 0k/dev/master | grep ^0k); do
  119. # git clone -s /var/git/$addons /opt/apps/openobject-addons/${addons%.git}
  120. # (cd /opt/apps/openobject-addons/${addons%.git}
  121. # git checkout 6.1/0k/prod/master ||
  122. # git checkout 0k/prod/master ||
  123. # git checkout 0k/dev/master ||
  124. # git checkout 6.1/simplee/prod/master ||
  125. # git checkout simplee/prod/master ||
  126. # git checkout simplee/dev/master ||
  127. # git checkout master
  128. # )
  129. # done
  130. #else
  131. # echo 'WARNING: skipping modules installation as directory was already existent !'
  132. #fi
  133. ## Install werkzeug from github last version
  134. ## because last PyPi version is 8.4 and we need the 9.0+
  135. (
  136. cd /tmp &&
  137. git clone https://github.com/mitsuhiko/werkzeug.git &&
  138. cd werkzeug &&
  139. python setup.py install
  140. )
  141. ##
  142. ## Linking with external filestore !
  143. ##
  144. (
  145. cd /opt/apps/0k-oe/openobject-server/openerp &&
  146. mkdir -p /var/openerp-filestore &&
  147. ln -sf /var/openerp-filestore filestore &&
  148. cd /var/openerp-filestore &&
  149. chown openerp .
  150. )
  151. ##
  152. ## Install 0k-manage for the handy oe command
  153. ##
  154. (
  155. if ! [ -d "/opt/apps/0k-manage" ]; then
  156. cd /opt/apps &&
  157. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" &&
  158. cd /opt/apps/0k-manage &&
  159. git checkout 0k/prod/master
  160. fi
  161. ## beurk
  162. ln -sf "/opt/apps/0k-manage/src/bin/oe" "/usr/local/bin/oe"
  163. )