#!/usr/bin/env bash # # Installs selected content from the downloaded repos into a production folder # if [ $UID != 0 ]; then echo "You need administration privileges to run this script." exit 1 fi DESTDIR=/opt/odoo OPTIONS="-av --exclude-from=common_exclude_patterns.txt --chown odoo:odoo" Help () { echo "Usage: $0 [-h] -o={all|core|community|apps|vendor|vendor01|custom}" echo echo "Options:" echo "-h Help (display this text)" echo "-o Modules to be installed (one of 'all', 'core', 'community'," echo " 'apps', 'vendor', 'vendor01', 'custom'). Required." echo } cp_core () { REPO="Odoo 14.0 core" SRC=./core/ DEST=$DESTDIR/core/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install $REPO into production directory structure" echo " …from $SRC to $DEST" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" rsync $OPTIONS $SRC $DEST } cp_community () { REPO="Modules by Odoo Community Association" SRC=./community/oca DEST=${DESTDIR}/community/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install ${REPO} into production directory structure" echo "(selected modules)" echo " …from ${SRC} to ${DEST}" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" while read -r line do [[ "$line" =~ ^# || "$line" =~ ^$ ]] && continue rsync ${OPTIONS} "${SRC}/${line%/}" ${DEST} done < selected_oca_modules.txt echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo " [!] Remember to apply patches to the installed code" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" } cp_apps () { REPO="Modules from Odoo Apps Store" SRC=./apps/ DEST=$DESTDIR/apps/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install $REPO into production directory structure" echo " …from $SRC to $DEST" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" rsync $OPTIONS $SRC $DEST } cp_vendor () { REPO="Avancys v14 for Agofer" SRC=./vendor/ DEST=$DESTDIR/vendor/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install $REPO into production directory structure" echo " …from $SRC to $DEST" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" rsync $OPTIONS $SRC $DEST echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" } cp_vendor01 () { REPO="Original e-invoice modules by Avancys" SRC=./vendor01/ DEST=$DESTDIR/vendor01/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install $REPO into production directory structure" echo " …from $SRC to $DEST" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" rsync $OPTIONS $SRC $DEST echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" } cp_custom () { REPO="Custom in-house modules " SRC=./custom/ DEST=$DESTDIR/custom/ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Install $REPO into production directory structure" echo " …from $SRC to $DEST" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" rsync $OPTIONS $SRC $DEST } cp_all () { cp_core # Install Odoo core cp_community # Install OCA modules cp_vendor # Install standard Avancys modules cp_vendor01 # Install replacement for removed Avancys modules cp_custom # Install Custom modules } set -ueo pipefail if (($# == 0)) then Help exit fi while getopts ":ho:" option; do case $option in h) # display Help Help exit;; o) # Enter a name Modules=$OPTARG;; *) # Invalid option echo "Error: Invalid option" echo Help exit;; esac done case $Modules in 'all') # Install all modules cp_all exit;; 'core') # Install Odoo core cp_core exit;; 'apps') # Install modules from Apps Store cp_apps exit;; 'community') # Install OCA modules cp_community exit;; 'vendor') # Install Avancys modules cp_vendor exit;; 'vendor01') # Install replacement for removed Avancys modules cp_vendor01 exit;; 'custom') # Install Custom modules developed in-house cp_custom exit;; *) # Invalid option echo "Error: Invalid module" echo Help exit;; esac echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "Remember to review patches that may need to be applied" echo " to code in ${DEST}" echo " by the script apply_patches.sh -o ${Modules}" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"