#!/bin/bash
#############################################################################
#                                                                           #
# This file is part of the "ubuntu" module of the otoolbox project.         #
#                                                                           #
# This script is open-source and intended for automation purposes.          #
# It is distributed in the hope that it will be useful, but WITHOUT         #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        #
# or FITNESS FOR A PARTICULAR PURPOSE.                                      #
#                                                                           #
# Use of this script is entirely at your own risk.                          #
#                                                                           #
# Copyright (c) The otoolbox contributors.                                  #
#############################################################################
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "$SCRIPT_DIR/bulk-common"
cd "$WORKSPACE_ROOT" || { echo "Error: failed to change directory to $WORKSPACE_ROOT" >&2; exit 1; }

# Constants
repos=(
    "auxico" \
    "account" \
    "brand" \
    "cnp" \
    "connector" \
    "docker-postgres" \
    "education" \
    "exchange" \
    "exchange-mp" \
    "gmt" \
    "gpu" \
    "gym" \
    "hr" \
    "iot" \
    "municipality" \
    "nesa" \
    "ocaoa" \
    "odoo-book-development" \
    "online" \
    "partner-contact" \
    "payment" \
    "pep" \
    "pos" \
    "product" \
    "purchase" \
    "sale" \
    "server-tools" \
    "server-ux" \
    "sms" \
    "social" \
    "stock" \
    "tb-gateway" \
    "website" \
)

customers=(
    "Auxico-Admin/Auxico" \
    "ethanmoonsun/odoo18" \
    "discoveryfloats/odoo19" \
    "AssociatedProjects/odoo18" \
    "globalstoneaus/global" \
    "marinesuppliesasialk/odoo19" \
    "nuedgeau-dotcom/odoo17Mildura" \
    "nuedgeau-dotcom/Odoo17Innisfail" \
    "CNPBrands/Odoo17" \
    "troyaau/odoo19" \
    "derucciau/odoo19" \
    "GMTLight/odoo17" \
    "Voltarioau/odoo18" \
    "emmengemal/eythimeethi" \
    "generalpump/odoo17" \
    "futuretechnologiesau/odoo18" \
    "prestigegolfau/odoo19" \
    "KianProActive/kian-Proactive" \
    "KianProActive/odoo" \
)


echo "---------------------------"
for project in "${repos[@]}"; do
    echo "> add repo: odoonix/$project"
    otoolbox --silent repo add "odoonix/$project"
done


echo "---------------------------"
for project in "${repos[@]}"; do
    echo "> add repo: moonsunsoft/$project"
    run_otoolbox_as_worker --silent repo add "moonsunsoft/$project"
done

echo "---------------------------"
for customer in "${customers[@]}"; do
    customer-init "$customer"
done
