2020-05-31 09:29:29 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -e
|
2025-08-07 06:28:34 -04:00
|
|
|
if [[ "$ENV" == "dev" ]] && [ ! -z ${CURRENT_UID} ]; then
|
|
|
|
|
export HOME=$ODOO_PREFIX
|
|
|
|
|
cd $HOME
|
|
|
|
|
|
|
|
|
|
# As it's only possible to fetch git repos manifest from an git url, we create one using git-daemon.
|
|
|
|
|
git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose &
|
|
|
|
|
GIT_PID=$!
|
|
|
|
|
echo "my repo" $(git rev-parse --abbrev-ref HEAD)
|
|
|
|
|
repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m default.dev.xml
|
2020-05-31 09:29:29 -04:00
|
|
|
|
2025-08-07 06:28:34 -04:00
|
|
|
repo sync -c -j $(nproc --all)
|
2020-05-31 09:29:29 -04:00
|
|
|
|
2025-08-07 06:28:34 -04:00
|
|
|
# After sync, terminate the git checkout. We don't need graceful kill as we don't do commit on the git repo during the operation.
|
|
|
|
|
kill -9 $GIT_PID
|
2020-05-31 09:29:29 -04:00
|
|
|
|
2025-08-07 06:28:34 -04:00
|
|
|
ls $HOME/odoo$(cat ".odoo-version" | xargs)/odoo/odoo-bin
|
|
|
|
|
# $? give the posix return value of the last command. 0 == success
|
|
|
|
|
# then IS_ODOO_FILE_EXIST : 0 == YES
|
|
|
|
|
IS_ODOO_FILE_EXIST=$?
|
2020-05-31 09:29:29 -04:00
|
|
|
|
2025-08-07 06:28:34 -04:00
|
|
|
if [ "$IS_ODOO_FILE_EXIST" -ne "0" ]; then
|
|
|
|
|
echo "The file $HOME/odoo$(cat ".odoo-version" | xargs)/odoo/odoo-bin doesnt exist. Verify entrypoint.sh"
|
2020-05-31 09:29:29 -04:00
|
|
|
exit 1
|
2025-08-07 06:28:34 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Add the odoo bins code on $PATH
|
|
|
|
|
echo PATH=$HOME/odoo$(cat ".odoo-version" | xargs)/odoo/:$PATH
|
|
|
|
|
|
|
|
|
|
# Configure an alias to use "odoo-bin" as "odoo".
|
|
|
|
|
alias odoo=odoo-bin
|
|
|
|
|
|
|
|
|
|
repo_manifest_gen_org_prefix_path.py $ODOO_PREFIX/addons $ODOO_RC $ODOO_PREFIX/odoo/odoo.conf && head $ODOO_PREFIX/odoo/odoo.conf
|
|
|
|
|
export ODOO_RC=$ODOO_PREFIX/odoo/odoo.conf
|
|
|
|
|
|
|
|
|
|
elif [[ "$ENV" == "dev" ]] && [ -z ${CURRENT_UID} ]; then
|
|
|
|
|
echo 'Please run as follows : CURRENT_UID=$(id -u):$(id -g) docker compose up'
|
|
|
|
|
exit 1
|
2020-05-31 09:29:29 -04:00
|
|
|
fi
|
|
|
|
|
|
2020-12-05 20:46:30 -05:00
|
|
|
# Fix volumes of odoo.conf if not exist
|
|
|
|
|
if [ ! -f "/etc/odoo/odoo.conf" ]; then
|
2025-08-07 06:28:34 -04:00
|
|
|
cp /odoo.conf /etc/odoo/odoo.conf
|
2020-12-05 20:46:30 -05:00
|
|
|
fi
|
|
|
|
|
|
2020-05-31 09:29:29 -04:00
|
|
|
# set the postgres database host, port, user and password according to the environment
|
|
|
|
|
# and pass them as arguments to the odoo process if not present in the config file
|
|
|
|
|
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
|
|
|
|
|
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
|
|
|
|
|
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
|
|
|
|
|
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
|
|
|
|
|
|
|
|
|
|
DB_ARGS=()
|
|
|
|
|
function check_config() {
|
2025-08-07 06:28:34 -04:00
|
|
|
param="$1"
|
|
|
|
|
value="$2"
|
|
|
|
|
if grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC"; then
|
|
|
|
|
value=$(grep -E "^\s*\b${param}\b\s*=" "$ODOO_RC" | cut -d " " -f3 | sed 's/["\n\r]//g')
|
|
|
|
|
fi
|
|
|
|
|
DB_ARGS+=("--${param}")
|
|
|
|
|
DB_ARGS+=("${value}")
|
2020-05-31 09:29:29 -04:00
|
|
|
}
|
|
|
|
|
check_config "db_host" "$HOST"
|
|
|
|
|
check_config "db_port" "$PORT"
|
|
|
|
|
check_config "db_user" "$USER"
|
|
|
|
|
check_config "db_password" "$PASSWORD"
|
|
|
|
|
|
2025-08-07 06:28:34 -04:00
|
|
|
cd /ERPLibre
|
|
|
|
|
source .venv.$(cat ".erplibre-version" | xargs)/bin/activate
|
|
|
|
|
|
2020-05-31 09:29:29 -04:00
|
|
|
case "$1" in
|
2025-08-07 06:28:34 -04:00
|
|
|
-- | odoo)
|
|
|
|
|
shift
|
|
|
|
|
if [[ "$1" == "scaffold" ]]; then
|
|
|
|
|
exec odoo "$@" || exec odoo-bin "$@"
|
|
|
|
|
else
|
|
|
|
|
cd $ODOO_PREFIX
|
|
|
|
|
if [[ "${STOP_BEFORE_INIT}" == "True" ]]; then
|
|
|
|
|
sleep 999999
|
|
|
|
|
fi
|
|
|
|
|
python3 ./docker/wait-for-psql.py "${DB_ARGS[@]}" --timeout=30
|
|
|
|
|
if [[ "${UPDATE_ALL_DB}" == "True" ]]; then
|
|
|
|
|
# --stop-after-init
|
|
|
|
|
python3 "$ODOO_EXEC_BIN" "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}"
|
|
|
|
|
else
|
|
|
|
|
python3 "$ODOO_EXEC_BIN" "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
-*)
|
|
|
|
|
cd $ODOO_PREFIX
|
|
|
|
|
if [[ "${STOP_BEFORE_INIT}" == "True" ]]; then
|
|
|
|
|
sleep 999999
|
|
|
|
|
fi
|
|
|
|
|
python3 ./docker/wait-for-psql.py "${DB_ARGS[@]}" --timeout=30
|
|
|
|
|
if [[ "${UPDATE_ALL_DB}" == "True" ]]; then
|
|
|
|
|
python3 "$ODOO_EXEC_BIN" "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}"
|
|
|
|
|
else
|
|
|
|
|
python3 "$ODOO_EXEC_BIN" "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
exec "$@"
|
|
|
|
|
;;
|
2020-05-31 09:29:29 -04:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
exit 1
|