From 618053b712fe307b6571fdfd0accb7f325a7bab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Garc=C3=ADa?= Date: Tue, 16 Jul 2024 14:14:52 +0200 Subject: [PATCH] Add env variables to autoconfigure --- docker-compose.yml | 6 ++++++ glpi-start.sh | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index edd2f309..e6ca342d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,4 +25,10 @@ services: - /var/www/html/glpi/:/var/www/html/glpi environment: - TIMEZONE=Europe/Brussels + - DB_HOST=mariadb + - DB_NAME=glpidb + - DB_USER=glpi_user + - DB_PASS=glpi + - REMOVE_INSTALL=true + - ENCRYPT_KEY=APpq+sK+bdSfoFEhQp4RMYzv/r5h/wiHBQ68gja4w/Y= restart: always diff --git a/glpi-start.sh b/glpi-start.sh index 5c1a3430..0eb80044 100644 --- a/glpi-start.sh +++ b/glpi-start.sh @@ -4,8 +4,8 @@ [[ ! "$VERSION_GLPI" ]] \ && VERSION_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -if [[ -z "${TIMEZONE}" ]]; then echo "TIMEZONE is unset"; -else +if [[ -z "${TIMEZONE}" ]]; then echo "TIMEZONE is unset"; +else echo "date.timezone = \"$TIMEZONE\"" > /etc/php/8.3/apache2/conf.d/timezone.ini; echo "date.timezone = \"$TIMEZONE\"" > /etc/php/8.3/cli/conf.d/timezone.ini; fi @@ -37,6 +37,44 @@ else chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} fi +# If DB_HOST is not empty, then update the config_db.php file +if [ -n "${DB_HOST}" ]; then + cat < /var/www/html/glpi/config/config_db.php + /var/www/html/glpi/config/glpicrypt.key + echo "Key generated ${GENERATED_KEY}" + echo "Key saved in /var/www/html/glpi/config/glpicrypt.key:" +else + #Decode the key and save it in the file + DECODED_KEY=$(echo "${ENCRYPTED_KEY}" | base64 --decode) + echo "${DECODED_KEY}" > /var/www/html/glpi/config/glpicrypt.key + echo "glpicrypt.key updated" +fi + +if [ "${REMOVE_INSTALL}" = "true" ]; then + # Remove install folder + rm -rf /var/www/html/glpi/install/ + echo "Folder INSTALL removed." +fi + #Adapt the Apache server according to the version of GLPI installed ## Extract local version installed LOCAL_GLPI_VERSION=$(ls ${FOLDER_WEB}/${FOLDER_GLPI}/version)