From 04345ec2ea5c0136b41dacff29ea8c349de8474b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Nov 2023 14:11:23 +0100 Subject: [PATCH] podman --- src/envole-1.0/.env | 2 + src/envole-1.0/docker-compose.yml | 39 +++++++++++-- src/envole-1.0/env/.env | 5 ++ src/envole-1.0/envole.sh | 93 ++++++++++++++++++++++++------- 4 files changed, 115 insertions(+), 24 deletions(-) create mode 100644 src/envole-1.0/.env diff --git a/src/envole-1.0/.env b/src/envole-1.0/.env new file mode 100644 index 0000000..54480b5 --- /dev/null +++ b/src/envole-1.0/.env @@ -0,0 +1,2 @@ +PODBIN=podman +PODCOMPOSEBIN=podman-compose \ No newline at end of file diff --git a/src/envole-1.0/docker-compose.yml b/src/envole-1.0/docker-compose.yml index e7a1550..666d375 100644 --- a/src/envole-1.0/docker-compose.yml +++ b/src/envole-1.0/docker-compose.yml @@ -10,6 +10,8 @@ services: interval: 1s timeout: 60s env_file: ./.env.local + networks: + - envole-network ports: - "3306:3306" volumes: @@ -17,7 +19,7 @@ services: - ./volume/mariadb/envole:/envole openldap: - image: docker.io/library/bitnami/openldap:2 + image: docker.io/bitnami/openldap:2 container_name: envole-openldap restart: always healthcheck: @@ -25,6 +27,8 @@ services: interval: 1s timeout: 60s env_file: ./.env.local + networks: + - envole-network ports: - '1389:1389' - '1636:1636' @@ -35,7 +39,7 @@ services: - './volume/openldap/envole:/envole' keycloak: - image: docker.io/library/jboss/keycloak + image: docker.io/jboss/keycloak container_name: envole-keycloak restart: always healthcheck: @@ -43,6 +47,8 @@ services: interval: 1s timeout: 60s env_file: ./.env.local + networks: + - envole-network ports: - 9000:8443 volumes: @@ -58,6 +64,8 @@ services: interval: 1s timeout: 60s env_file: ./.env.local + networks: + - envole-network ports: - "9001:80" volumes: @@ -73,6 +81,8 @@ services: interval: 1s timeout: 60s env_file: ./.env.local + networks: + - envole-network ports: - 9002:80 volumes: @@ -83,17 +93,38 @@ services: - ./volume/nextcloud/prestart:/docker-entrypoint-hooks.d/before-starting adminer: - image: adminer + image: docker.io/library/adminer container_name: envole-adminer restart: always + env_file: ./.env.local + networks: + - envole-network ports: - 9100:8080 phpldapadmin: - image: osixia/phpldapadmin:latest + image: docker.io/osixia/phpldapadmin:latest container_name: envole-phpldapadmin restart: always env_file: ./.env.local + networks: + - envole-network ports: - "9101:80" + nineapache: + image: reg.cadoles.com/envole/nineapache:7.4 + container_name: envole-nineapache + restart: always + healthcheck: + test: curl --fail http://localhost || exit 1 + interval: 1s + timeout: 60s + env_file: ./.env.local + networks: + - envole-network + ports: + - "9002:80" + +networks: + envole-network: \ No newline at end of file diff --git a/src/envole-1.0/env/.env b/src/envole-1.0/env/.env index e83b94d..8bfc777 100644 --- a/src/envole-1.0/env/.env +++ b/src/envole-1.0/env/.env @@ -74,4 +74,9 @@ PHPLDAPADMIN_ACTIVATE=0 PHPLDAPADMIN_LOCAL=1 PHPLDAPADMIN_URL=http://localhost:9001 +# NINEAPACHE +NINEAPACHE_SERVICE_NAME=nineapache +NINEAPACHE_ACTIVATE=0 +NINEAPACHE_LOCAL=1 +NINEAPACHE_URL=http://localhost:9002 diff --git a/src/envole-1.0/envole.sh b/src/envole-1.0/envole.sh index 4b2cef7..90325a8 100755 --- a/src/envole-1.0/envole.sh +++ b/src/envole-1.0/envole.sh @@ -6,8 +6,50 @@ # Fusionner l'ensemble des fichier .env en un seul rm -f ./.env.local cat ./env/.env* >> ./.env.local +. ./.env.local + + +# on remplace les valeur reprise dans les autres .env car podman interprète mal +#while IFS= read -r match; do +# eval "val=\${$match}" +# echo ${ADMIN_PASSWORD} +# echo ${match} +# echo ${!match} +# echo $val +# sed -i "s/${match}/${val}/g" ./.env.local +#done < <(grep -oP '\$\{\w+\}' ./.env.local) + + +sed -i 's#${ADMIN_PASSWORD}#'${ADMIN_PASSWORD}'#g' ./.env.local +sed -i 's#${ADMIN_USER}#'${ADMIN_USER}'#g' ./.env.local + +sed -i 's#${CAS_HOST}#'${CAS_HOST}'#g' ./.env.local +sed -i 's#${CAS_PORT}#'${CAS_PORT}'#g' ./.env.local +sed -i 's#${CAS_USER}#'${CAS_USER}'#g' ./.env.local +sed -i 's#${CAS_PASSWORD}#'${CAS_PASSWORD}'#g' ./.env.local + +sed -i 's#${LDAP_SERVICE_NAME}#'${LDAP_SERVICE_NAME}'#g' ./.env.local +sed -i 's#${LDAP_ADMIN_USERNAME}#'${LDAP_ADMIN_USERNAME}'#g' ./.env.local +sed -i 's#${LDAP_BASEDN}#'${LDAP_BASEDN}'#g' ./.env.local +sed -i 's#${LDAP_PASSWORD}#'${LDAP_PASSWORD}'#g' ./.env.local +sed -i 's#${LDAP_USER}#'${LDAP_USER}'#g' ./.env.local +sed -i 's#${LDAP_PORT}#'${LDAP_PORT}'#g' ./.env.local + +sed -i 's#${MARIADB_SERVICE_NAME}#'${MARIADB_SERVICE_NAME}'#g' ./.env.local +sed -i 's#${MARIADB_USER}#'${MARIADB_USER}'#g' ./.env.local +sed -i 's#${MARIADB_PASSWORD}#'${MARIADB_PASSWORD}'#g' ./.env.local + +sed -i 's#${ADMINER_ACTIVATE}#'${ADMINER_ACTIVATE}'#g' ./.env.local +sed -i 's#${ADMINER_URL}#'${ADMINER_URL}'#g' ./.env.local + +sed -i 's#${PHPLDAPADMIN_ACTIVATE}#'${PHPLDAPADMIN_ACTIVATE}'#g' ./.env.local +sed -i 's#${PHPLDAPADMIN_URL}#'${PHPLDAPADMIN_URL}'#g' ./.env.local + +sed -i 's#${NEXTCLOUD_ACTIVATE}#'${NEXTCLOUD_ACTIVATE}'#g' ./.env.local +sed -i 's#${NEXTCLOUD_URL}#'${NEXTCLOUD_URL}'#g' ./.env.local # Include +. .env . ./misc/tools/e-ihm.sh . ./env/.env . ./env/.env.local @@ -23,7 +65,7 @@ BigTitle "ENVOLE" stop() { Title "STOP" - docker-compose stop $1 + $PODCOMPOSEBIN stop $1 } #=========================================================================================================================================== @@ -33,13 +75,13 @@ stop() { wait_for_container() { container_id="envole-$1" - container_name="$(docker inspect "${container_id}" --format '{{ .Name }}')" + container_name="$($PODBIN inspect "${container_id}" --format '{{ .Name }}')" waiting_done="false" while [[ "${waiting_done}" != "true" ]]; do - container_state="$(docker inspect "${container_id}" --format '{{ .State.Status }}')" + container_state="$($PODBIN inspect "${container_id}" --format '{{ .State.Status }}')" if [[ "${container_state}" == "running" ]]; then - health_status="$(docker inspect "${container_id}" --format '{{ .State.Health.Status }}')" + health_status="$($PODBIN inspect "${container_id}" --format '{{ .State.Health.Status }}')" if [[ ${health_status} == "healthy" ]]; then waiting_done="true" fi @@ -51,7 +93,7 @@ wait_for_container() { } upservice(){ - docker-compose up -d $1 + $PODCOMPOSEBIN up -d $1 wait_for_container $1 } @@ -75,19 +117,19 @@ up(){ if [[ $CAS_ACTIVATE == 1 && $CAS_LOCAL == 1 ]] then EchoVert ${CAS_SERVICE_NAME^^} - docker-compose exec $MARIADB_SERVICE_NAME /envole/init.sh $CAS_SERVICE_NAME + $PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $CAS_SERVICE_NAME fi if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]] then EchoVert ${NINEGATE_SERVICE_NAME^^} - docker-compose exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEGATE_SERVICE_NAME + $PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEGATE_SERVICE_NAME fi if [[ $NEXTCLOUD_ACTIVATE == 1 && $NEXTCLOUD_LOCAL == 1 ]] then EchoVert ${NEXTCLOUD_SERVICE_NAME^^} - docker-compose exec $MARIADB_SERVICE_NAME /envole/init.sh $NEXTCLOUD_SERVICE_NAME + $PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NEXTCLOUD_SERVICE_NAME fi # OPENLDAP @@ -97,8 +139,10 @@ up(){ mkdir -p ./volume/openldap/data chmod a+wr ./volume/openldap/data + + #$PODCOMPOSEBIN up -d $LDAP_SERVICE_NAME upservice $LDAP_SERVICE_NAME - docker-compose exec $LDAP_SERVICE_NAME /envole/init.sh + $PODCOMPOSEBIN exec $LDAP_SERVICE_NAME /envole/init.sh fi # CAS @@ -116,7 +160,8 @@ up(){ if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]] then EchoVert ${NINEGATE_SERVICE_NAME^^} - upservice ${NINEGATE_SERVICE_NAME} + $PODCOMPOSEBIN up -d $NINEGATE_SERVICE_NAME + #upservice ${NINEGATE_SERVICE_NAME} echo fi @@ -131,19 +176,26 @@ up(){ if [[ $ADMINER_ACTIVATE == 1 && $ADMINER_LOCAL == 1 ]] then EchoVert ${ADMINER_SERVICE_NAME^^} - docker-compose up -d ${ADMINER_SERVICE_NAME} + $PODCOMPOSEBIN up -d ${ADMINER_SERVICE_NAME} echo fi if [[ $PHPLDAPADMIN_ACTIVATE == 1 && $PHPLDAPADMIN_LOCAL == 1 ]] then EchoVert ${PHPLDAPADMIN_SERVICE_NAME^^} - docker-compose up -d ${PHPLDAPADMIN_SERVICE_NAME} + $PODCOMPOSEBIN up -d ${PHPLDAPADMIN_SERVICE_NAME} echo fi + + if [[ $NINEAPACHE_ACTIVATE == 1 && $NINEAPACHE_LOCAL == 1 ]] + then + EchoVert ${NINEAPACHE_SERVICE_NAME^^} + $PODCOMPOSEBIN up -d ${NINEAPACHE_SERVICE_NAME} + echo + fi else EchoVert ${1^^} - docker-compose up -d $1 + $PODCOMPOSEBIN up -d $1 fi } @@ -165,7 +217,7 @@ then EchoRouge "Vous devez precisez un service" EchoRouge "envole.sh bash monservice" else - docker-compose exec $2 "/bin/bash" + $PODCOMPOSEBIN exec $2 "/bin/bash" fi elif [[ $1 == "destroy" ]] then @@ -174,9 +226,11 @@ then EchoRouge "Vous devez precisez un service" EchoRouge "envole.sh bash monservice" else - docker-compose stop $2 - docker-compose rm $2 - + $PODCOMPOSEBIN down $2 + $PODCOMPOSEBIN rm $2 + + echo $2 + echo $LDAP_SERVICE_NAME if [[ "$2" == "$LDAP_SERVICE_NAME" && $LDAP_ACTIVATE == 1 && $LDAP_LOCAL == 1 ]] then sudo rm -rf volume/openldap/data @@ -190,15 +244,14 @@ then Question_ouinon "Souhaitez-vous supprimer la BDD associé à $2 ?" if [ "$?" = 0 ] then - docker-compose exec $MARIADB_SERVICE_NAME /envole/delete.sh $CAS_SERVICE_NAME + $PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/delete.sh $CAS_SERVICE_NAME fi fi fi elif [[ $1 == "env" ]] then - rm -f ./.env.local - cat ./env/.env* >> ./.env.local + EchoVert Fichier .env.local regénéré fi echo echo \ No newline at end of file