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.

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