From 815cc5ed5535e85e261960852c739df567e81245 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Aug 2020 10:03:42 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20de=20bug=20dans=20glpi=5Finit.sh?= =?UTF-8?q?=20Remplacement=20de=20supervisor=20par=20runit=20Correction=20?= =?UTF-8?q?de=20cron=20qui=20ne=20semble=20pas=20s'ex=C3=A9cuter=20normale?= =?UTF-8?q?ment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 18 +++++++++--------- glpi.cron | 2 +- glpi_init.sh | 10 ++++++++++ service/apache2/run | 2 ++ service/cron/run | 6 ++++++ service/glpi_init/run | 3 +++ supervisor/conf.d/apache2.conf | 9 ++++++--- supervisor/conf.d/cron.conf | 9 ++++++--- supervisor/conf.d/glpi_init.conf | 5 ++++- supervisor/supervisord.conf | 7 ++++--- 10 files changed, 51 insertions(+), 20 deletions(-) create mode 100755 service/apache2/run create mode 100755 service/cron/run create mode 100755 service/glpi_init/run diff --git a/Dockerfile b/Dockerfile index 62d9344..ee461e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,13 @@ WORKDIR /root ENV GLPI_CONFIG_DIR=/etc/glpi ENV GLPI_VAR_DIR=/var/lib/glpi ENV GLPI_LOG_DIR=/var/log/glpi +ENV GLPI_VERSION=9.5.1 +ENV FUSIONINVENTORY_VERSION=9.5.0+1.0 RUN \ apt-get update && \ apt-get install --no-install-recommends -y \ - supervisor \ + runit \ cron \ libbz2-dev \ libzip-dev \ @@ -33,14 +35,12 @@ docker-php-ext-configure opcache && docker-php-ext-install opcache COPY CAS-1.3.8.tgz /root/ RUN pear install /root/CAS-1.3.8.tgz -COPY supervisor/supervisord.conf /etc/supervisor/ -COPY supervisor/conf.d/apache2.conf /etc/supervisor/conf.d/ -COPY supervisor/conf.d/cron.conf /etc/supervisor/conf.d/ -COPY supervisor/conf.d/glpi_init.conf /etc/supervisor/conf.d/ +#COPY supervisor/ /etc/supervisor/ +COPY service/ /etc/service/ COPY glpi_init.sh /root/glpi_init.sh COPY glpi.cron /etc/cron.d/glpi -ADD https://github.com/glpi-project/glpi/releases/download/9.5.1/glpi-9.5.1.tgz /root/glpi-9.5.1.tgz -ADD https://github.com/fusioninventory/fusioninventory-for-glpi/releases/download/glpi9.5.0%2B1.0/fusioninventory-9.5.0+1.0.tar.bz2 /root/fusioninventory-9.5.0+1.0.tar.bz2 +ADD https://github.com/glpi-project/glpi/releases/download/${GLPI_VERSION}/glpi-${GLPI_VERSION}.tgz /root/glpi-${GLPI_VERSION}.tgz +ADD https://github.com/fusioninventory/fusioninventory-for-glpi/releases/download/glpi${FUSIONINVENTORY_VERSION}/fusioninventory-${FUSIONINVENTORY_VERSION}.tar.bz2 /root/fusioninventory-${FUSIONINVENTORY_VERSION}.tar.bz2 RUN \ chmod a+x /root/glpi_init.sh && \ @@ -48,5 +48,5 @@ rm -f /var/www/html/* /root/CAS-1.3.8.tgz && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisor/supervisord.conf"] - +#ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisor/supervisord.conf"] +ENTRYPOINT ["/usr/bin/runsvdir", "-P", "/etc/service"] diff --git a/glpi.cron b/glpi.cron index de84665..2803a1d 100644 --- a/glpi.cron +++ b/glpi.cron @@ -1 +1 @@ -* * * * * www-data /usr/local/bin/php /var/www/html/front/cron.php &>/dev/null +*/1 * * * * www-data /usr/local/bin/php /var/www/html/front/cron.php diff --git a/glpi_init.sh b/glpi_init.sh index 4bdacef..dae1ee3 100644 --- a/glpi_init.sh +++ b/glpi_init.sh @@ -12,6 +12,7 @@ echo "Starting glpi configuration..." } if [ -z $(ls -A /var/www/html) ] ; then + init_db echo "Initilazing ${GLPI_TARBALL}" cd /root tar xf ${GLPI_TARBALL} @@ -35,6 +36,14 @@ EOF else echo "GLPI is already initialized" cd /var/www/html + GLPI_ACTUAL_VERSION=$(awk -F", '" '/^define\(.GLPI_VERSION/ { print $2 }' inc/define.php | sed 's/\([0-9\.]*\).*/\1/') + FUSIONINVENTORY_ACTUAL_VERSION=$(awk -F', "' '/^define \(.PLUGIN_FUSIONINVENTORY_VERSION/ { print $2 }' plugins/fusioninventory/setup.php | sed 's/\([0-9\.+]*\).*/\1/') + if [ "${GLPI_ACTUAL_VERSION}" = "${GLPI_VERSION}" -a "${FUSIONINVENTORY_ACTUAL_VERSION}" = "${FUSIONINVENTORY_VERSION}" ] ; then + echo GLPI already up2date + exit + fi + init_db + php bin/console glpi:maintenance:enable -n php bin/console glpi:plugin:deactivate fusioninventory -n cd /root tar xf ${GLPI_TARBALL} @@ -45,5 +54,6 @@ else rm /var/www/html/install/install.php cd /var/www/html php bin/console db:update --config-dir=${GLPI_CONFIG_DIR} -n + php bin/console glpi:maintenance:disable -n chown -R www-data:www-data /var/www/html /etc/glpi /var/lib/glpi /var/log/glpi fi diff --git a/service/apache2/run b/service/apache2/run new file mode 100755 index 0000000..eed6d08 --- /dev/null +++ b/service/apache2/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec apache2-foreground diff --git a/service/cron/run b/service/cron/run new file mode 100755 index 0000000..890e6c2 --- /dev/null +++ b/service/cron/run @@ -0,0 +1,6 @@ +#!/bin/sh + +# Touch cron files to fix 'NUMBER OF HARD LINKS > 1' issue. See https://github.com/phusion/baseimage-docker/issues/198 +touch -c /etc/crontab /etc/cron.*/* /var/spool/cron/crontabs/* + +exec /usr/sbin/cron -f diff --git a/service/glpi_init/run b/service/glpi_init/run new file mode 100755 index 0000000..1627eb8 --- /dev/null +++ b/service/glpi_init/run @@ -0,0 +1,3 @@ +#!/bin/sh +/root/glpi_init.sh +sleep infinity diff --git a/supervisor/conf.d/apache2.conf b/supervisor/conf.d/apache2.conf index d2b3d6c..8acf518 100644 --- a/supervisor/conf.d/apache2.conf +++ b/supervisor/conf.d/apache2.conf @@ -1,4 +1,7 @@ [program:apache2] -command=apache2-foreground -autostart=true -autorestart=true +command = apache2-foreground +autostart = true +autorestart = true +redirect_stderr = true +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 diff --git a/supervisor/conf.d/cron.conf b/supervisor/conf.d/cron.conf index 85f4a1b..4b856f6 100644 --- a/supervisor/conf.d/cron.conf +++ b/supervisor/conf.d/cron.conf @@ -1,4 +1,7 @@ [program:cron] -command=cron -f -L 15 -autostart=true -autorestart=true +command = cron -f +autostart = true +autorestart = true +redirect_stderr = true +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 diff --git a/supervisor/conf.d/glpi_init.conf b/supervisor/conf.d/glpi_init.conf index e4169a4..471d501 100644 --- a/supervisor/conf.d/glpi_init.conf +++ b/supervisor/conf.d/glpi_init.conf @@ -1,5 +1,8 @@ [program:glpi_init] -command=/root/glpi_init.sh +command = /root/glpi_init.sh startsecs = 0 autorestart = false startretries = 1 +redirect_stderr = true +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 diff --git a/supervisor/supervisord.conf b/supervisor/supervisord.conf index 79e5836..f33948d 100644 --- a/supervisor/supervisord.conf +++ b/supervisor/supervisord.conf @@ -1,9 +1,10 @@ ; supervisor config file [supervisord] -logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) -pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) -childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +logfile = /var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +childlogdir = /var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +user = root ; The [include] section can just contain the "files" setting. This ; setting can list multiple files (separated by whitespace or