Mauro Rosero P
c1721b5168
- Se agrega archivo entrypoint.sh a plantillas de configuración - Se agrega funcionalidad para copiar plantilla entrypoint.sh a la raíz del proyecto - Otras modificaciones menores
233 lines
5.1 KiB
Bash
Executable file
233 lines
5.1 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# configure.sh
|
|
# Modified: 2024/12/04 14:47:00
|
|
# Derechos de Autor (C) [2024] [Mauro Rosero P. <mauro@roser.one>]
|
|
#
|
|
# Este programa es software libre: usted puede redistribuirlo y/o modificarlo
|
|
# bajo los términos de la Licencia Pública Affero General de GNU tal como
|
|
# lo publica la Free Software Foundation, ya sea la versión 3 de la licencia,
|
|
# o (a su elección) cualquier versión posterior.
|
|
#
|
|
# Este programa se distribuye con la esperanza de que sea útil,
|
|
# pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
|
|
# COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la
|
|
# Licencia Pública Affero General de GNU para obtener más detalles.
|
|
#
|
|
# Debería haber recibido una copia de la Licencia Pública Affero General
|
|
# junto con este programa. Si no la recibió, consulte <https://www.gnu.org/licenses/>.
|
|
|
|
DEVSPATH=developers
|
|
DEVSTEAM=odoo
|
|
BIN_HOME=$HOME/$DEVSPATH/$DEVSTEAM
|
|
BIN_MESG=bin/msg
|
|
BIN_LIBS=bin/lib
|
|
VERSION="$(cat $BIN_HOME/config/project.version)"
|
|
DATENOW="$(date +"%Y-%m-%d %H:%M:%S")"
|
|
|
|
# CHECK SHELL LANGUAGE
|
|
BIN_LANG=${LANG:0:2}
|
|
|
|
# LOAD BASE BASH LIBRARY
|
|
source $BIN_HOME/$BIN_LIBS/base.lib
|
|
#baselib_test
|
|
|
|
# LOAD CONSOLE BASH LIBRARY
|
|
source $BIN_HOME/$BIN_LIBS/console.lib
|
|
APPS_NAME="$(cat $BIN_HOME/$DEVS_NAME)"
|
|
#consolelib_test
|
|
|
|
# LOAD ODOO BASH LIBRARY
|
|
source $BIN_HOME/$BIN_LIBS/odoo.lib
|
|
#odoolib_test
|
|
|
|
# Load head messages
|
|
load_messages $BIN_HOME $BIN_MESG $BIN_LANG "head"
|
|
|
|
# Load odoo messages
|
|
load_messages $BIN_HOME $BIN_MESG $BIN_LANG "odoo"
|
|
|
|
# Function to display help message
|
|
function help() {
|
|
echo "$odmsg_003_1 $0 $odmsg_019_2"
|
|
echo "$odmsg_004"
|
|
echo "$odmsg_005"
|
|
echo "$odmsg_006"
|
|
echo "$odmsg_007"
|
|
}
|
|
|
|
function odoo_configure_form() {
|
|
|
|
local env_template=$2
|
|
|
|
declare -a response c_lbl, c_hlp, c_mod, c_opt, c_val, c_dat, c_def
|
|
|
|
# Input: Versión Postgresql
|
|
c_lbl[0]="${odlbl_000}"
|
|
c_hlp[0]="${odhlp_000}"
|
|
c_mod[0]=1
|
|
c_opt[0]=0
|
|
c_def[0]="$ODOO_DEF_DBPG"
|
|
c_val[0]=013
|
|
c_dat[0]="${ODOO_CFG_DBPG[@]}"
|
|
# Input: Path Postgresql DB
|
|
c_lbl[1]="${odlbl_001}"
|
|
c_hlp[1]="${odhlp_001}"
|
|
c_mod[1]=1
|
|
c_opt[1]=0
|
|
c_def[1]="$BIN_HOME/data/${PROJECT_NAME}/db"
|
|
c_val[1]=0
|
|
c_dat[1]=""
|
|
# Input: Path Odoo Data
|
|
c_lbl[2]="${odlbl_002}"
|
|
c_hlp[2]="${odhlp_002}"
|
|
c_mod[2]=1
|
|
c_opt[2]=0
|
|
c_val[2]=0
|
|
c_def[2]="$BIN_HOME/data/${PROJECT_NAME}/files"
|
|
c_dat[2]=""
|
|
# Input: Path Odoo Backup
|
|
c_lbl[3]="${odlbl_003}"
|
|
c_hlp[3]="${odhlp_003}"
|
|
c_mod[3]=1
|
|
c_opt[3]=0
|
|
c_val[3]=0
|
|
c_def[3]="$BIN_HOME/backups/$PROJECT_NAME"
|
|
c_dat[3]=""
|
|
# Input: Odoo Port
|
|
c_lbl[4]="${odlbl_004}"
|
|
c_hlp[4]="${odhlp_004}"
|
|
c_mod[4]=1
|
|
c_opt[4]=0
|
|
c_val[4]=014
|
|
c_def[4]="${ODOO_PFX_BASE}${ODOO_CRR_PORT}"
|
|
c_dat[4]="$ODOO_BSE_RANG"
|
|
# Input: Odoo Chat Port
|
|
c_lbl[5]="${odlbl_005}"
|
|
c_hlp[5]="${odhlp_005}"
|
|
c_mod[5]=1
|
|
c_opt[5]=0
|
|
c_val[5]=014
|
|
c_def[5]="${ODOO_PFX_CHAT}${ODOO_CRR_PORT}"
|
|
c_dat[5]="$ODOO_CHT_RANG"
|
|
# Input: Odoo Container
|
|
c_lbl[6]="${odlbl_006}"
|
|
c_hlp[6]="${odhlp_006}"
|
|
c_mod[6]=1
|
|
c_opt[6]=0
|
|
c_val[6]=0
|
|
c_def[6]="${PROJECT_NAME//./_}"
|
|
c_dat[6]=""
|
|
# Input: Versión Odoo
|
|
c_lbl[7]="${odlbl_007}"
|
|
c_hlp[7]="${odhlp_007}"
|
|
c_mod[7]=1
|
|
c_opt[7]=0
|
|
c_def[7]="${ODOO_DEF_VERS}"
|
|
c_val[7]=013
|
|
c_dat[7]="${ODOO_CFG_VALS[@]}"
|
|
# Input count
|
|
c_end=8
|
|
|
|
dialog_form
|
|
if [ $? -eq 0 ]
|
|
then
|
|
# Check if bash environment template file exists
|
|
if [[ ! -f "$BIN_HOME/config/odoo_devs.env" ]]; then
|
|
dialog_error_box "${head_error}" "${odmsg_020}"
|
|
return 10
|
|
fi
|
|
# Create project bash environment file (.env)
|
|
eval "echo \"$(cat $BIN_HOME/config/odoo_devs.env)\"" > $BIN_HOME/$PROJECT_NAME/.env
|
|
fi
|
|
}
|
|
|
|
########### MAIN PROGRAM ###########
|
|
|
|
# Check if dialog is not installed, exited!
|
|
if ! command -v dialog >/dev/null 2>&1
|
|
then
|
|
display_text_header $BIN_HOME "${odmsg_000} ${odmsg_101}"
|
|
echo "${head_001}"
|
|
exit 200
|
|
fi
|
|
|
|
# Check for arguments option
|
|
help=false
|
|
version=false
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--help)
|
|
help=true
|
|
shift
|
|
;;
|
|
--version)
|
|
version=true
|
|
shift
|
|
;;
|
|
*)
|
|
if [[ -z $PROJECT_NAME ]]; then
|
|
PROJECT_NAME="$1"
|
|
shift
|
|
else
|
|
help
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Check to show help
|
|
if $help; then
|
|
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 program title
|
|
title="$(cat < $BIN_HOME/config/project.head) ${odmsg_000}"
|
|
apps_title="${odmsg_101} ${PROJECT_NAME^^}"
|
|
|
|
# Check if os is valid!
|
|
get_osname
|
|
if [ "${os_name}" == "${head_unknow}" ]
|
|
then
|
|
dialog_error_box "${head_error}" "${head_os_error}"
|
|
exit 3
|
|
fi
|
|
|
|
# Configure odoo devs environment for project
|
|
dialog_yesno "${odmsg_201} ${PROJECT_NAME}?"
|
|
case ${result} in
|
|
0)
|
|
odoo_configure_form
|
|
case $? in
|
|
0)
|
|
dialog_error_box "${head_info}" "${odmsg_021}"
|
|
clear
|
|
exit 0
|
|
;;
|
|
*)
|
|
dialog_error_box "${head_info}" "${head_op_error}"
|
|
;;
|
|
esac
|
|
;;
|
|
*)
|
|
dialog_error_box "${head_info}" "${head_op_error}"
|
|
;;
|
|
esac
|
|
|
|
# Clear console and exit
|
|
clear
|
|
exit 0
|