nextcloud-cronjob/scripts/entrypoint.sh
Robert Dailey 08ec92f509 Add extra logs and debugging features
* New DEBUG environment variable enables `set -x` in shell scripts for
  extra verbose output for debugging custom cron scripts and to assist
  with development of the core scripts.
* Verify if we can find the Nextcloud container on start up. Fail if
  not.
* Print information about how we will search for Nextcloud on start up.
* During cron task execution, the ID of the Nextcloud container is
  printed, if found.
2020-08-28 14:52:00 -05:00

32 lines
916 B
Bash
Executable file

#!/usr/bin/env bash
set -e
[[ ! -z "$DEBUG" ]] && set -x
if [[ -z "$NEXTCLOUD_CONTAINER_NAME" ]]; then
echo "NEXTCLOUD_CONTAINER_NAME is a required variable"
exit 1
fi
# Print info about how we will look for Nextcloud
if [[ -n "$NEXTCLOUD_PROJECT_NAME" ]]; then
echo "Will search for Nexcloud container as a Docker Compose service"
echo "Project: $NEXTCLOUD_PROJECT_NAME, Service: $NEXTCLOUD_CONTAINER_NAME"
else
echo "Container Name: $NEXTCLOUD_CONTAINER_NAME"
fi
# Do an initial search for the container to rule out any configuration problems
containerId="$(/find-container.sh)"
if [[ -z "$containerId" ]]; then
echo "ERROR: Unable to find the Nextcloud container"
exit 1
else
echo "Found Nextcloud container with ID $containerId"
fi
echo "*/$NEXTCLOUD_CRON_MINUTE_INTERVAL * * * * /cron-tasks.sh" \
> /var/spool/cron/crontabs/root
echo "Starting crond"
exec crond -f -l 0