Ajout de l'initialisation de glpi et de fusioninventory au script d'init. Reste à tester et corriger la mise à jour

This commit is contained in:
root 2020-08-04 17:27:46 +02:00
parent 5073a9efa2
commit 9cda96d277
5 changed files with 51 additions and 9 deletions

View File

@ -2,6 +2,9 @@ FROM php:7.4-apache-buster
MAINTAINER Benoit LORAND <benoit.lorand@blorand.org>
WORKDIR /root
ENV GLPI_CONFIG_DIR=/etc/glpi
ENV GLPI_VAR_DIR=/var/lib/glpi
ENV GLPI_LOG_DIR=/var/log/glpi
RUN \
apt-get update && \
@ -15,6 +18,7 @@ apt-get install --no-install-recommends -y \
libicu-dev \
libpng-dev \
zlib1g-dev \
default-mysql-client \
&& \
pecl install apcu && docker-php-ext-enable apcu && \
docker-php-ext-configure mysqli && docker-php-ext-install mysqli && \

View File

@ -7,7 +7,11 @@ services:
ports:
- 8089:80
volumes:
- ./www:/var/www/html
- ./etc/:/etc/glpi/
- ./files/:/var/lib/glpi/
- ./log/:/var/log/glpi/
env_file:
- ./mysql_settings.ini
depends_on:
- db
@ -16,10 +20,7 @@ services:
container_name: glpi-db
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
environment:
MYSQL_DATABASE: mysql_db_name
MYSQL_USER: mysql_db_user
MYSQL_PASSWORD: mysql_db_password
MYSQL_RANDOM_ROOT_PASSWORD: '1'
env_file:
- ./mysql_settings.ini
volumes:
- ./db:/var/lib/mysql
- ./db/:/var/lib/mysql/

View File

@ -1 +1 @@
* * * * * root /usr/local/bin/php /var/www/html/front/cron.php &>/dev/null
* * * * * www-data /usr/local/bin/php /var/www/html/front/cron.php &>/dev/null

View File

@ -2,15 +2,48 @@
GLPI_TARBALL="/root/glpi-9.5.1.tgz"
FUSION_TARBALL="/root/fusioninventory-9.5.0+1.0.tar.bz2"
init_db() {
while ! mysqlshow -h db -uroot -p${MYSQL_ROOT_PASSWORD} | grep "^| ${MYSQL_DATABASE}" > /dev/null 2>&1 ; do
echo "Waiting for mysql database initilization..."
sleep 5
done
echo "Starting glpi configuration..."
}
if [ -z $(ls -A /var/www/html) ] ; then
echo "Initilazing ${GLPI_TARBALL}"
cd /root
tar xf ${GLPI_TARBALL}
cp -r /root/glpi/config/. /etc/glpi/.
cp -r /root/glpi/files/. /var/lib/glpi/.
rm -r /root/glpi/config /root/glpi/files
cp -r /root/glpi/. /var/www/html/.
cd /var/www/html/plugins
tar xf ${FUSION_TARBALL}
chown -R www-data:www-data /var/www/html
rm -r /root/glpi
mysql --host=db --user=root --password=${MYSQL_ROOT_PASSWORD} << EOF
use mysql;
GRANT SELECT ON time_zone_name TO '${MYSQL_USER}'@'%';
EOF
cd /var/www/html
php bin/console db:install --config-dir=${GLPI_CONFIG_DIR} -L fr_FR -H db -d ${MYSQL_DATABASE} -u ${MYSQL_USER} -p ${MYSQL_PASSWORD} -n
php bin/console glpi:plugin:install -u glpi fusioninventory -n
php bin/console glpi:plugin:activate fusioninventory -n
rm install/install.php
chown -R www-data:www-data /var/www/html /etc/glpi /var/lib/glpi /var/log/glpi
else
echo "GLPI is already initialized"
cd /var/www/html
php bin/console glpi:plugin:deactivate fusioninventory -n
cd /root
tar xf ${GLPI_TARBALL}
rm -r glpi/config glpi/files /var/www/html
mv glpi /var/www/html
cd /var/www/html/plugins
tar xf ${FUSION_TARBALL}
rm /var/www/html/install/install.php
cd /var/www/html
php bin/console db:update --config-dir=${GLPI_CONFIG_DIR} -n
chown -R www-data:www-data /var/www/html /etc/glpi /var/lib/glpi /var/log/glpi
fi

4
mysql_settings.ini Normal file
View File

@ -0,0 +1,4 @@
MYSQL_DATABASE=
MYSQL_USER=
MYSQL_PASSWORD=''
MYSQL_ROOT_PASSWORD=''