Checklist
I have read intro post: About the Installation Issues category
I have read the tutorials, help and searched for similar issues
I provide relevant information about my server (component names and versions, etc.)
I provide a copy of my logs and healthcheck
I describe the steps I have taken to trouble shoot the problem
I describe the steps on how to reproduce the issue
Hi,
I have a working passbolt pro-non-root setup with LDAP activated.
In the docker-compose.yaml file is the following command section:
command:
- /bin/bash
- -c
- |
# Uncomment line below if you are using ldap sync. Change '* * * * *' to your preferred sync schedule. More info: https://en.wikipedia.org/wiki/Cron
# echo '* * * * * www-data exec /bin/bash -c "source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all" >> /var/log/cron.log 2>&1' >> /etc/cron.d/passbolt-pro-server
/usr/bin/wait-for.sh -t 0 db:3306 -- /docker-entrypoint.sh
I uncommented the second line to synchronize LDAP via cron, but got the following error after starting the container:
/bin/bash: line 2: /etc/cron.d/passbolt-pro-server: Permission denied
The file /etc/cron.d/passbolt-pro-server
is owned by root, so it seems valid that the non root image cannot write there.
After putting the line
* * * * * www-data exec /bin/bash -c "source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all" >> /var/log/cron.log 2>&1' >> /etc/cron.d/passbolt-pro-server
by hand into /etc/cron.d/passbolt-pro-server
I got the following errors during cron execution:
passbolt_1 time="xxx" level=info msg="/bin/sh: 1: cannot create /var/log/cron.log: Permission denied" channel=stderr iteration=0 job.command="www-data exec /bin/bash -c \"source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all\" >> /var/log/cron.log 2>&1" job.position=1 job.schedule="*/15 * * * *"
passbolt_1 time="xxx" level=error msg="error running command: exit status 2" iteration=0 job.command="www-data exec /bin/bash -c \"source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all\" >> /var/log/cron.log 2>&1" job.position=1 job.schedule="*/15 * * * *"
I touch
ed and chmod
ed www-data:www-data /var/log/cron.log
and proceeded to the next errors in /var/log/cron.log
:
/bin/sh: 1: www-data: not found
So I changed the cron job
* * * * * www-data exec /bin/bash -c "source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all" >> /var/log/cron.log 2>&1' >> /etc/cron.d/passbolt-pro-server
to
* * * * * /bin/bash -c "source /etc/environment && /usr/share/php/passbolt/bin/cake directory_sync all" >> /var/log/cron.log 2>&1' >> /etc/cron.d/passbolt-pro-server
Since the image is non root, the cron job is executed by www-data and it worked this way.
Though the sync still not worked:
# /var/log/cron.log
Warning: check config and pass option --persist to actually modify data. Running in dry-run mode.
At the end my cron job looks like this (added --persist):
* * * * * /bin/bash -c "source /etc/environment && $PASSBOLT_BASE_DIR/bin/cake directory_sync all --persist" >> /var/log/cron.log 2>&1
Issues to solve:
- How can I write the cronjob during command execution in docker-compose.yml.
- Update docs for non-root docker image