[IMPROVED] Creación de proyecto odoo nuevo

- Se copian los modulos apps (base, ia y devs) desde los packs. Esto es el sistema de aplicaciones odoo base
This commit is contained in:
Mauro Rosero P. 2024-12-03 11:02:16 -05:00
parent 950ddac250
commit 56770254a1
Signed by: mrosero
GPG key ID: 83BD2A5F674B7E26
4 changed files with 135 additions and 20 deletions

View file

@ -38,6 +38,7 @@ function load_messages() {
fi
}
# Display text header apps
function display_text_header() {
local PROJECT=$1
local tittle=$2
@ -47,6 +48,8 @@ function display_text_header() {
echo "=========================================================="
}
# Verify if your program or command is installed
function command_installed() {
local PROGRAM=$1
@ -59,6 +62,7 @@ function command_installed() {
return 1
}
# Install os packages
function os_pkgs_install() {
local PACKAGE=$1
@ -114,6 +118,7 @@ function os_update() {
}
# Check for container manager installed
function container_mode() {
command_installed "podman"

View file

@ -31,14 +31,39 @@ ODOO_CFG=config
ODOO_SET=odoo.conf
ODOO_LOG=odoo.log
ODOO_DEF_VERS="18"
ODOO_CFG_VARS=("18")
ODOO_PKG_BASE=base
ODOO_PKG_DEVS=devs
ODOO_PKG_INAR=ia
ODOO_CFG_PREF=odoo.v
ODOO_CFG_BASE=odoo.base.conf
ODOO_CFG_SAAS=odoo.saas.conf
ODOO_CFG_PACK=packs
# Test odoo library
function odoolib_test() {
echo "Odoo Library loaded!"
}
# Check for odoo version supported
function odoo_verscheck() {
local value=$1
for item in "${ODOO_CFG_VARS[@]}"
do
if [[ "$item" == "$value" ]]
then
return 0
fi
done
return 1
}
# Create odoo project structured path
function odoo_structure() {
@ -59,6 +84,7 @@ function odoo_structure() {
fi
fi
fi
}
# Copy docker file to build
@ -76,6 +102,7 @@ function copy_dockerfile() {
echo "[x] $odmsg_009"
fi
fi
}
# Copy odoo config template file to etc
@ -93,6 +120,7 @@ function copy_odooconfig() {
echo "[x] $odmsg_010 $ODOOFILE"
fi
fi
}
# Create new odoo log file
@ -109,4 +137,23 @@ function create_odoolog() {
echo "[x] $odmsg_011"
fi
fi
}
# Copy odoo/version modules to apps
function copy_odooapps() {
local ODOO_PATH=$1
local ODOO_PROJ=$2
local APPS=$4
local VERSION=$3
cp -rf $ODOO_PATH/$ODOO_CFG_PACK/${ODOO_CFG_PREF}${VERSION}/${APPS} "$ODOO_PATH/$ODOO_PROJ/$ODOO_APP/"
if [ $? -eq 0 ]
then
echo "[x] $odmsg_012_1 $APPS $odmsg_012_2"
else
echo "[-] $odmsg_012_1 $APPS $odmsg_012_3"
fi
}

View file

@ -15,7 +15,7 @@ odmsg_000="(ODOO TOOLS)"
odmsg_001="- INICIALIZACIÓN"
odmsg_002="Ambiente de desarrollo Odoo no instalado!"
odmsg_003_1="Uso:"
odmsg_003_2="<project path> [--help] [--version]"
odmsg_003_2="<project path> [--help] [--version] [--odoo <n>]"
odmsg_004="Descripción: Este script requiere un argumento obligatorio."
odmsg_005="Opciones:"
odmsg_006=" --help Muestra este mensaje de ayuda."
@ -25,3 +25,10 @@ odmsg_008_2="fue creada!"
odmsg_009="Dockerfile fue creado!"
odmsg_010="odoo.conf creado desde"
odmsg_011="Archivo de auditoria odoo (odoo.log) fue inicializado!"
odmsg_012_1="Paquete de odoo"
odmsg_012_2="ha sido actualizado!"
odmsg_012_3="no fue actualizado!"
odmsg_013="Error: Se requiere un argumento para --odoo."
odmsg_014_1="Versión de Odoo"
odmsg_014_2="no es soportada!"
odmsg_015=" --odoo <n> Identifica la versión de odoo a configurar. Default:"

View file

@ -48,39 +48,95 @@ function help() {
echo "$odmsg_005"
echo "$odmsg_006"
echo "$odmsg_007"
echo "$odmsg_015 $ODOO_DEF_VERS"
}
# Display Headers
display_text_header $BIN_HOME "${odmsg_000} ${odmsg_001}"
# Check for arguments option
for arg in "$@"; do
case $arg in
--help)
help
exit 0
;;
--version)
echo "$head_version $VERSION"
exit 0
;;
esac
help=false
version=false
while [[ $# -gt 0 ]]; do
case $1 in
--help)
help=true
shift
;;
--version)
version=true
shift
;;
--odoo)
if [[ -n $2 ]]; then
ODOO_VERS="$2"
shift 2
else
echo "$odmsg_013"
exit 1
fi
;;
*)
if [[ -z $PROJECT_NAME ]]; then
PROJECT_NAME="$1"
shift
else
help
echo "zzzzzzzz"
exit 1
fi
;;
esac
done
# Check if mandatory argument is provided
if [ -z "$1" ]; then
help
exit 1
# Check to show help
if $help; then
help
echo "$help"
exit 0
fi
# Check to show command version
if $version; then
echo "$head_version $VERSION"
exit 0
fi
# Check for empty project path
if [[ -z $PROJECT_NAME ]]; then
help
exit 1
fi
# Set odoo default version, if odoo version is not defined
if [[ ! -n $ODOO_VERS ]]; then
ODOO_VERS=$ODOO_DEF_VERS
fi
# Check if odoo version is supported
odoo_verscheck ODOO_VERS
if [ $? -eq 0 ]; then
echo "[-] $odmsg_014_1 $ODOO_VERS $odmsg_014_2"
exit 2
fi
# Create odoo project path
odoo_structure $BIN_HOME "$1"
odoo_structure $BIN_HOME "$PROJECT_NAME"
# Copy dockerfile template file to build (local)
copy_dockerfile $BIN_HOME "$1" "$BIN_HOME/$ODOO_CFG/$DOCKER_LOCAL"
copy_dockerfile $BIN_HOME "$PROJECT_NAME" "$BIN_HOME/$ODOO_CFG/$DOCKER_LOCAL"
# Copy odoo config template file to etc (base)
copy_odooconfig $BIN_HOME "$1" "$BIN_HOME/$ODOO_CFG/$ODOO_CFG_BASE"
copy_odooconfig $BIN_HOME "$PROJECT_NAME" "$BIN_HOME/$ODOO_CFG/$ODOO_CFG_BASE"
# Create odoo.log on etc
create_odoolog $BIN_HOME "$1"
create_odoolog $BIN_HOME "$PROJECT_NAME"
# Copy odoo base apps to project
copy_odooapps $BIN_HOME "$PROJECT_NAME" "${ODOO_VERS}" $ODOO_PKG_BASE
# Copy odoo devs apps to project
copy_odooapps $BIN_HOME "$PROJECT_NAME" "${ODOO_VERS}" $ODOO_PKG_DEVS
# Copy odoo ai apps to project
copy_odooapps $BIN_HOME "$PROJECT_NAME" "${ODOO_VERS}" $ODOO_PKG_INAR