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.

31 lines
1.0 KiB

8 months ago
  1. #!/bin/bash
  2. CLIENT=$1
  3. ADDON=$2
  4. function usage() {
  5. echo 'usage: <CLIENT> <ADDON>'
  6. exit 1
  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/odoo12-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/12.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. chown -R odoo:odoo /tmp/ADDON/
  21. mv /tmp/ADDON/odoo/addons/* /home/odoo/data-${CLIENT}/addons/12.0/
  22. echo "FORCE RELOADING ADDONS with: ./web?debug#menu_id=48&action=36"