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.

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