provisioning tool for building opinionated architecture
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.

33 lines
1.2 KiB

8 months ago
  1. #!/bin/bash
  2. CLIENT=$1
  3. ADDON=$2
  4. function usage() {
  5. echo 'usage: <CLIENT> <ADDON>'
  6. exit 100
  7. }
  8. # VERIFICATION
  9. [[ -z "$CLIENT" || -z "$ADDON" ]] && usage
  10. [[ ! -d "/home/odoo/data-${CLIENT}" ]] && echo "unknown CLIENT <${CLIENT}>, should exist in folder /home/odoo/data-..." && exit 2
  11. URL="https://pypi.org/project/odoo-addon-${ADDON}/"
  12. curl --output /dev/null --silent --head --fail "${URL}"
  13. [[ $? -ne 0 ]] && echo "unknown ADDON <${ADDON}>, should be downloadable from: ${URL}" && exit 3
  14. [[ -d "/home/odoo/data-${CLIENT}/addons/15.0/${ADDON}" ]] && echo "ADDON <${ADDON}> already exists, consider removing manually!" && exit 4
  15. # ACTION
  16. package=$(curl -Ls "$URL" | rg '<a href="(https://files.pythonhosted.org/.*)">' -r '$1')
  17. wget $package -O /tmp/package.zip
  18. rm /tmp/ADDON -rf && mkdir /tmp/ADDON
  19. unzip /tmp/package.zip 'odoo/addons/*' -d /tmp/ADDON/
  20. real_name=$(unzip -l /tmp/package.zip | head -n4 | tail -n1 | cut -d'/' -f3)
  21. chown -R odoo:odoo /tmp/ADDON/
  22. mv /tmp/ADDON/odoo/addons/* "/home/odoo/data-$CLIENT/addons/15.0/"
  23. # ADD
  24. su odoo -c "python3.9 /home/odoo/odoo15/odoo-bin -c /etc/odoo15/$CLIENT.conf -i $real_name -d odoo15-$CLIENT --worker=0 --stop-after-init"