nextcloud-cronjob/scripts/cron-tasks.sh
Robert Dailey e9b5772dae
Allow configuration of user used for task execution
New NEXTCLOUD_EXEC_USER environment variable added which allows control over which
user is used to execute cron tasks inside the Nextcloud container. By default, the
user is `www-data`. If the environment variable is specified but empty, no `--user`
option is provided to `docker exec`.
2019-01-11 21:08:39 -06:00

24 lines
818 B
Bash
Executable file

#!/usr/bin/env bash
set -e
echo "-------------------------------------------------------------"
echo " Executing Cron Tasks: $(date)"
echo "-------------------------------------------------------------"
# If a user must be specified when executing the task, set up that option here.
# You may also leave NEXTCLOUD_EXEC_USER blank, in which case it will not be used.
if [[ -n "$NEXTCLOUD_EXEC_USER" ]]; then
exec_user="--user $NEXTCLOUD_EXEC_USER"
fi
# Loop through all shell scripts and execute the contents of those scripts in the Nextcloud
# container. It's done this way so that the user may mount more scripts to be executed in addition
# to the default ones.
cd /cron-scripts
for script in *.sh; do
echo "> Running Script: $script"
docker exec $exec_user -i "$1" bash < $script
done
echo "> Done"