Add Support for Cron

- Resolves #65
This commit is contained in:
Wilton Rodrigues 2021-11-04 13:56:22 -03:00 committed by Wilton Rodrigues
parent 0b60593438
commit 6f1cfcdcbc
3 changed files with 50 additions and 4 deletions

View File

@ -23,6 +23,7 @@ RUN yum ${YUM_FLAGS} install wget \
yum-utils \
tar \
make \
crontabs \
yum ${YUM_FLAGS} install epel-release ; \
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ; \
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm ; \
@ -63,6 +64,10 @@ RUN yum ${YUM_FLAGS} install wget \
php73-php-zip \
php73-php-opcache ;
# https://wiki.ocsinventory-ng.org/03.Basic-documentation/Understanding-OCS-Crontab/
RUN mkdir -p /var/spool/cron; \
echo '*/30 * * * * cd /usr/share/ocsinventory-reports/ocsreports/crontab; for cron in $(ls cron*.php); do date --iso-8601=s; echo "Executing cron: ${cron}"; /usr/bin/php73 ${cron}; done' > /var/spool/cron/apache
RUN wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/${OCS_VERSION}/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -P /tmp && \
tar xzf /tmp/OCSNG_UNIX_SERVER-${OCS_VERSION}.tar.gz -C /tmp;
@ -82,7 +87,7 @@ RUN sed -ri \
"/etc/httpd/conf/httpd.conf"
COPY conf/ /tmp/conf
COPY ./scripts/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
COPY ./scripts/*.sh /usr/bin/
EXPOSE 80 443

View File

@ -25,7 +25,7 @@ services:
networks:
- localocs
depends_on:
- ocsdb
- ocsdb
ocsdb :
image : mysql:5.7
@ -43,7 +43,24 @@ services:
MYSQL_DATABASE : ocsweb
networks:
- localocs
ocscron:
image: ocsinventory/ocsinventory-docker-image:2.9
container_name : ocsinventory-cron
restart: always
command: /usr/bin/cron.sh
environment:
OCS_DB_SERVER: ocsinventory-db
OCS_DB_USER: ocsuser
OCS_DB_PASS: ocspass
OCS_DB_NAME: ocsweb
links:
- ocsdb
networks:
- localocs
depends_on:
- ocsdb
networks:
localocs:
@ -53,4 +70,4 @@ volumes:
varlibdata:
httpdconfdata:
sqldata:

24
2.9/scripts/cron.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
set -eu
echo "+------------------------------------------------------------+"
echo "| Starting OCS Inventory Cron Management Docker... |"
echo "+------------------------------------------------------------+"
exec crond -n -P -x sch
# Usage:
# crond [options]
#
# Options:
# -h print this message
# -i deamon runs without inotify support
# -m <comm> off, or specify prefered client for sending mails
# -n run in foreground
# -p permit any crontab
# -P use PATH="/usr/bin:/bin"
# -c enable clustering support
# -s log into syslog instead of sending mails
# -x <flag> print debug information
#
# Debugging flags are: ext,sch,proc,pars,load,misc,test,bit