Mauro Rosero P
7aa3910a61
- Se agrega opción --remote a project.sh para actualizar repositorio remoto. Default: no - Otras modificaciones menores
188 lines
4.5 KiB
Bash
Executable file
188 lines
4.5 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# project.sh
|
|
# Modified: 2024/12/01 15:27: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)"
|
|
|
|
# CHECK SHELL LANGUAGE
|
|
BIN_LANG=${LANG:0:2}
|
|
|
|
# LOAD BASE BASH LIBRARY
|
|
source $BIN_HOME/$BIN_LIBS/base.lib
|
|
#baselib_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_003_2"
|
|
echo "$odmsg_004"
|
|
echo "$odmsg_005"
|
|
echo "$odmsg_006"
|
|
echo "$odmsg_007"
|
|
echo "$odmsg_023"
|
|
echo "$odmsg_015 $ODOO_DEF_VERS"
|
|
}
|
|
|
|
# Display Headers
|
|
display_text_header $BIN_HOME "${odmsg_000} ${odmsg_001}"
|
|
|
|
# Check for arguments option
|
|
help=false
|
|
version=false
|
|
remote=false
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--help)
|
|
help=true
|
|
shift
|
|
;;
|
|
--version)
|
|
version=true
|
|
shift
|
|
;;
|
|
--remote)
|
|
remote=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
|
|
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 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 [ $? -ne 0 ]; then
|
|
echo "[-] $odmsg_014_1 $ODOO_VERS $odmsg_014_2"
|
|
exit 2
|
|
fi
|
|
|
|
# Create odoo project path
|
|
odoo_structure $BIN_HOME "$PROJECT_NAME"
|
|
|
|
# Copy dockerfile template file to build (local)
|
|
copy_dockerfile $BIN_HOME "$PROJECT_NAME" "$BIN_HOME/$ODOO_CFG/$DOCKER_LOCAL" "$DOCKER_FILE"
|
|
|
|
# Copy entrypoint template file to build (local)
|
|
copy_entrypoint $BIN_HOME "$PROJECT_NAME" "$BIN_HOME/$ODOO_CFG/$DOCKER_ENTRY" "$DOCKER_ENTRY"
|
|
|
|
# Copy odoo config template file to etc (base)
|
|
copy_odooconfig $BIN_HOME "$PROJECT_NAME" "$BIN_HOME/$ODOO_CFG/$ODOO_CFG_BASE"
|
|
|
|
# Create odoo.log on etc
|
|
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
|
|
|
|
# Initialize git repository
|
|
if [ ! -d "$BIN_HOME/$PROJECT_NAME/.git" ]
|
|
then
|
|
result=$(git_init "$BIN_HOME/$PROJECT_NAME" "${ODOO_DEF_BRCH}${ODOO_VERS}")
|
|
if [ $? -eq 0 ]; then
|
|
echo "[x] $result"
|
|
echo "[x] $git_setbranch: ${ODOO_DEF_BRCH}${ODOO_VERS}"
|
|
cp -f $BIN_HOME/$ODOO_CFG/$ODOO_CFG_GITI $BIN_HOME/$PROJECT_NAME/$GIT_IGNORE
|
|
echo "[x] $git_gitignored $ODOO_CFG_GITI"
|
|
else
|
|
echo echo "[-] $git_notinitialized"
|
|
fi
|
|
|
|
result=$(git_add_full "$BIN_HOME/$PROJECT_NAME")
|
|
if [ $? -eq 0 ]; then
|
|
echo "[x] $git_add_files"
|
|
else
|
|
echo "$result"
|
|
fi
|
|
|
|
result=$(git_commit "$BIN_HOME/$PROJECT_NAME" "$git_first_commited")
|
|
if [ $? -eq 0 ]; then
|
|
echo "[x] $git_end_commited"
|
|
else
|
|
echo "$result"
|
|
fi
|
|
|
|
if $remote; then
|
|
result=$(git_new_project "$BIN_HOME/$PROJECT_NAME" "$ODOO_GIT_REPOS" "${PROJECT_NAME//./_}" "${ODOO_DEF_BRCH}${ODOO_VERS}")
|
|
if [ $? -eq 0 ]; then
|
|
echo "[x] $git_new_project_pushed"
|
|
else
|
|
echo "$result"
|
|
fi
|
|
fi
|
|
|
|
fi
|
|
|