autoriser les url courtes pour les orga
This commit is contained in:
@@ -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
|
||||
|
||||
Executable
+106
@@ -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
|
||||
Reference in New Issue
Block a user