autoriser les url courtes pour les orga

This commit is contained in:
nom
2026-06-04 10:44:19 +02:00
parent 3dc8376974
commit 108161da5f
2 changed files with 107 additions and 0 deletions
+1
View File
@@ -89,6 +89,7 @@ for ARG in "$@"; do
ln -sf ../../config/orgaTmpl/orga-gen.sh
ln -sf ../../config/orgaTmpl/orga-rm.sh
ln -sf ../../config/orgaTmpl/reload.sh
ln -sf ../../config/orgaTmpl/orga-simplifie-url.sh
else
printKazError "Name must contains only a-z0-9_\-"
usage
+106
View File
@@ -0,0 +1,106 @@
#!/bin/bash
#KI: fab
#KOI: créer des url simplifiée sans le suffixe (-wp ou -cloud)
#KAN: 04/06/2026
PRG=$(basename $0)
KAZ_ROOT=$(cd "$(dirname $0)/../.."; pwd)
. "${KAZ_ROOT}/bin/.commonFunctions.sh"
setKazVars
cd $(dirname $0)
ORGA_DIR="$(basename "$(pwd)")"
usage(){
echo "Usage: $0 [-h|--help] [+cloud|+wp]"
echo
echo " -h|--help : this help"
echo " +cloud : simplifie l'url du cloud"
echo " +wp : simplifie l'url du wp"
}
#quelle orga ?
ORGA=${ORGA_DIR%-orga}
#quel choix ?
MODE=""
for ARG in "$@"; do
case "$ARG" in
-h|--help)
usage
exit 0
;;
+cloud|+wp)
if [ -n "$MODE" ]; then
echo "Une seule option est autorisée : +cloud ou +wp"
exit 1
fi
MODE="$ARG"
;;
*)
echo "Option invalide : $ARG"
usage
exit 1
;;
esac
done
OVERRIDE_FILE="compose.override.yml"
# sauvegarde si le fichier existe déjà
if [ -f "$OVERRIDE_FILE" ]; then
cp "$OVERRIDE_FILE" "${OVERRIDE_FILE}.$(date +%Y%m%d-%H%M%S).bak"
fi
#on récupère toutes les variables utiles
set -a
source .env
set +a
# quel Traitement ?
case "$MODE" in
##########################
+cloud)
echo "TODO: Traitement cloud pour l'orga ${ORGA}"
;;
##########################
+wp)
echo "Traitement wordpress pour l'orga ${ORGA}"
#creer le compose-override.yml
cat > "$OVERRIDE_FILE" <<EOF
services:
wordpress:
labels:
- "traefik.enable=true"
- "traefik.http.routers.${ORGA}-${wordpressServName}.rule=Host(\`${ORGA}-${wordpressHost}.${domain}\`) || Host(\`${ORGA}.${domain}\`)"
EOF
echo "$OVERRIDE_FILE créé"
#les variables
set -a
source /kaz/secret/orgas/${ORGA}/env-wpDB
set +a
#maj DB avec la nouvelle url
docker exec -i ${ORGA}-DB mariadb \
-uroot \
-p"$MYSQL_ROOT_PASSWORD" \
"$MYSQL_DATABASE" \
-e "update wp_options set option_value='${ORGA}\.${domain}' where option_name in ('siteurl','home');"
#restart orga
docker-compose down && docker-compose up -d
;;
"")
echo "Aucune option fournie - ARRET"
;;
esac