2018-12-02 02:08:31 +01:00
|
|
|
#!/usr/bin/env bash
|
2018-12-07 00:30:27 +01:00
|
|
|
set -e
|
2023-11-09 09:02:19 +01:00
|
|
|
[[ -n "$DEBUG" ]] && set -x
|
2018-12-02 02:08:31 +01:00
|
|
|
|
2020-08-28 21:52:50 +02:00
|
|
|
source /nextcloud-exec.sh
|
|
|
|
|
2018-12-07 00:30:27 +01:00
|
|
|
echo "-------------------------------------------------------------"
|
|
|
|
echo " Executing Cron Tasks: $(date)"
|
|
|
|
echo "-------------------------------------------------------------"
|
|
|
|
|
2019-06-21 02:15:55 +02:00
|
|
|
# Obtain the ID of the container. We do this each iteration since the Nextcloud container may be
|
|
|
|
# recreated while the cron container is still running. We will need to check for a new container ID
|
|
|
|
# each time.
|
|
|
|
containerId="$(/find-container.sh)"
|
|
|
|
if [[ -z "$containerId" ]]; then
|
|
|
|
echo "ERROR: Unable to find the Nextcloud container"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-08-28 21:45:17 +02:00
|
|
|
echo "> Nextcloud Container ID: ${containerId}"
|
|
|
|
|
2020-08-28 21:52:50 +02:00
|
|
|
run_scripts_in_dir() {
|
|
|
|
cd "$1"
|
2020-10-27 22:45:16 +01:00
|
|
|
find . -type f -name '*.sh' -print0 |
|
|
|
|
while IFS= read -r -d '' file; do
|
|
|
|
echo "> Running Script: $file"
|
2023-11-09 09:02:19 +01:00
|
|
|
nextcloud_exec "$containerId" "$(cat "$file")" || continue
|
2020-08-28 21:52:50 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-12-07 00:30:27 +01:00
|
|
|
# Loop through all shell scripts and execute the contents of those scripts in the Nextcloud
|
2020-10-26 19:55:10 +01:00
|
|
|
# container.
|
|
|
|
run_scripts_in_dir /cron-scripts-builtin
|
|
|
|
|
|
|
|
# If the user has mounted their own scripts, execute those as well. These are optional. It's done
|
|
|
|
# this way so that the user may mount more scripts to be executed in addition to the default ones.
|
|
|
|
if [[ -d /cron-scripts ]]; then
|
|
|
|
run_scripts_in_dir /cron-scripts
|
|
|
|
fi
|
2018-12-07 00:30:27 +01:00
|
|
|
|
|
|
|
echo "> Done"
|