deploy dolibarr
This commit is contained in:
26
chart/scripts/custom_entrypoint.sh
Normal file
26
chart/scripts/custom_entrypoint.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Fichier original du script Docker
|
||||
DOCKER_RUN_SCRIPT="/usr/local/bin/docker-run.sh"
|
||||
APACHE_CONF="/etc/apache2/sites-enabled/000-default.conf"
|
||||
|
||||
# 1. Remplacement de la commande MySQL par PSQL dans docker-run.sh
|
||||
if [[ ${DOLI_DB_TYPE} == "pgsql" ]]; then
|
||||
sed -i 's/mysql -u \${DOLI_DB_USER} -p\${DOLI_DB_PASSWORD} -h \${DOLI_DB_HOST} -P \${DOLI_DB_HOST_PORT} \${DOLI_DB_NAME} < \${file}/PGPASSWORD="\${DOLI_DB_PASSWORD}" psql -U "\${DOLI_DB_USER}" -h "\${DOLI_DB_HOST}" -p "\${DOLI_DB_HOST_PORT}" -d "\${DOLI_DB_NAME}" < \${file}/' "$DOCKER_RUN_SCRIPT"
|
||||
fi
|
||||
|
||||
# 2. Mise à jour de la configuration Apache pour définir dynamiquement ServerName
|
||||
if [ -n "$DOLI_URL_ROOT" ]; then
|
||||
# Supprimer le préfixe "https://" ou "http://" si présent
|
||||
SERVER_NAME=$(echo "$DOLI_URL_ROOT" | sed 's|https\?://||')
|
||||
|
||||
# Utiliser le nom de domaine extrait comme ServerName
|
||||
sed -i "s|#ServerName www.example.com|ServerName $SERVER_NAME|" "$APACHE_CONF"
|
||||
echo 'ServerName $SERVER_NAME' >> /etc/apache2/apache2.conf
|
||||
else
|
||||
echo "Avertissement: DOLI_URL_ROOT non défini, aucun changement de ServerName effectué."
|
||||
fi
|
||||
|
||||
# 3. Exécution du script d'origine avec les arguments passés au wrapper
|
||||
exec "$DOCKER_RUN_SCRIPT" "$@"
|
||||
19
chart/scripts/update_conf_db_credentials.sh
Normal file
19
chart/scripts/update_conf_db_credentials.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Chemin vers le fichier de configuration
|
||||
CONFIG_FILE="/var/www/html/conf/conf.php"
|
||||
|
||||
set -eu
|
||||
# Variables d'environnement pour les secrets
|
||||
DB_USER="${DOLI_DB_USER}"
|
||||
DB_PASS="${DOLI_DB_PASSWORD}"
|
||||
|
||||
# Utilisation de sed pour remplacer les valeurs dans conf.php
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
echo "mise à jour du fichier $CONFIG_FILE"
|
||||
sed -i "s/^\(\$dolibarr_main_db_user\s*=\s*\).*/\1'${DB_USER}';/" "$CONFIG_FILE"
|
||||
sed -i "s/^\(\$dolibarr_main_db_pass\s*=\s*\).*/\1'${DB_PASS}';/" "$CONFIG_FILE"
|
||||
else
|
||||
echo "Fichier de configuration non trouvé : $CONFIG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
21
chart/scripts/update_ownership.sql
Normal file
21
chart/scripts/update_ownership.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- PGPASSWORD=${DOLI_DB_PASSWORD} psql -U ${DOLI_DB_USER} -h ${DOLI_DB_HOST} -p ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME}
|
||||
DO $$
|
||||
DECLARE
|
||||
current_schema_owner VARCHAR; -- Propriétaire actuel du schéma public
|
||||
BEGIN
|
||||
|
||||
-- Obtenir le nom du propriétaire actuel du schéma 'public'
|
||||
SELECT tableowner INTO current_schema_owner
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
LIMIT 1;
|
||||
|
||||
-- Si le propriétaire actuel est différent de erp_role
|
||||
IF current_schema_owner <> 'erp_role' THEN
|
||||
-- Construire et exécuter la requête REASSIGN OWNED BY
|
||||
EXECUTE format('REASSIGN OWNED BY %I TO %I', current_schema_owner, 'erp_role');
|
||||
RAISE NOTICE 'Ownership of all objects in schema "public" has been reassigned from % to %', current_schema_owner, 'erp_role';
|
||||
ELSE
|
||||
RAISE NOTICE 'No change needed; the owner of schema "public" is already %', 'erp_role';
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user