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.

215 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_SETUP_OPTIONS=${GIT_0K_SUB_SETUP_OPTIONS:-""}
  13. ## 0k git default checkout reference (for 0k-oe root package)
  14. GIT_0K_CHECKOUT_REF=${GIT_0K_CHECKOUT_REF:-"7.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
  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 clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE"/0k/0k-oe.git &&
  98. cd /opt/apps/0k-oe &&
  99. git checkout "$GIT_0K_CHECKOUT_REF" &&
  100. git sub setup $GIT_0K_SUB_SETUP_OPTIONS -r
  101. )
  102. adduser --system --home=/var/lib/openerp --group openerp
  103. ## XXXvlab: warning password in charm !!
  104. cp -i etc/openerp-server.conf /etc/
  105. sed -ri "s/%%PASSWORD%%/$OPENERP_PASSWORD/g" /etc/openerp-server.conf
  106. cp -i etc/init.d/openerp-server /etc/init.d/
  107. chown openerp /etc/openerp-server.conf
  108. chmod 600 /etc/openerp-server.conf
  109. chown openerp /etc/init.d/openerp-server
  110. update-rc.d openerp-server defaults
  111. mkdir /var/log/openerp
  112. touch /var/log/openerp/openerp-server.log
  113. chown openerp /var/log/openerp -R
  114. cp -i etc/default/openerp-server /etc/default/openerp-server
  115. ## Install add-ons
  116. ## make a better way for installing add-ons
  117. #addons_path=/opt/apps/openobject-addons/0k
  118. #if ! [ -d "$addons_path" ]; then
  119. # mkdir -p $addons_path
  120. # for addons in $(/var/git/list-addons 0k/dev/master | grep ^0k); do
  121. # git clone -s /var/git/$addons /opt/apps/openobject-addons/${addons%.git}
  122. # (cd /opt/apps/openobject-addons/${addons%.git}
  123. # git checkout 6.1/0k/prod/master ||
  124. # git checkout 0k/prod/master ||
  125. # git checkout 0k/dev/master ||
  126. # git checkout 6.1/simplee/prod/master ||
  127. # git checkout simplee/prod/master ||
  128. # git checkout simplee/dev/master ||
  129. # git checkout master
  130. # )
  131. # done
  132. #else
  133. # echo 'WARNING: skipping modules installation as directory was already existent !'
  134. #fi
  135. ## Install werkzeug from github last version
  136. ## because last PyPi version is 8.4 and we need the 9.0+
  137. (
  138. cd /tmp &&
  139. git clone https://github.com/mitsuhiko/werkzeug.git &&
  140. cd werkzeug &&
  141. python setup.py install
  142. )
  143. ##
  144. ## Linking with external filestore !
  145. ##
  146. (
  147. cd /opt/apps/0k-oe/openobject-server/openerp &&
  148. mkdir -p /var/openerp-filestore &&
  149. ln -sf /var/openerp-filestore filestore &&
  150. cd /var/openerp-filestore &&
  151. chown openerp .
  152. )
  153. ##
  154. ## Install 0k-manage for the handy oe command
  155. ##
  156. (
  157. if ! [ -d "/opt/apps/0k-manage" ]; then
  158. cd /opt/apps &&
  159. git clone $GIT_0K_CLONE_OPTIONS "$GIT_0K_BASE/0k/0k-manage.git" &&
  160. cd /opt/apps/0k-manage &&
  161. git checkout 0k/prod/master
  162. fi
  163. ## beurk
  164. ln -sf "/opt/apps/0k-manage/src/bin/oe" "/usr/local/bin/oe"
  165. )