Fix various custom script processing issues
The following issues were addressed. Note that these are edge cases. * If an empty `/cron-scripts` directory was mounted in the container, an error would occur. * If files in the `/cron-scripts` directory had spaces in the name, this would cause issues. * stdin was held open when running `docker exec` which would cause hangs and other issues. The `exec` command is now run non-interactively. * Custom scripts that failed would interrupt processing of scripts after it, if any.
This commit is contained in:
parent
ff71477632
commit
f2ce54653b
3 changed files with 7 additions and 4 deletions
|
@ -213,6 +213,8 @@ above. However, it is explicitly specified for example purposes.
|
||||||
* All cron task shell scripts run at the same interval defined by `NEXTCLOUD_CRON_MINUTE_INTERVAL`.
|
* All cron task shell scripts run at the same interval defined by `NEXTCLOUD_CRON_MINUTE_INTERVAL`.
|
||||||
* Modification of your own shell scripts on the host do not require that you restart/recreate the
|
* Modification of your own shell scripts on the host do not require that you restart/recreate the
|
||||||
container (only when volume mappings change in the YAML file).
|
container (only when volume mappings change in the YAML file).
|
||||||
|
* If a custom script in the `/cron-scripts` directory fails, it will not impede the processing of
|
||||||
|
other scripts in the directory.
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,10 @@ echo "> Nextcloud Container ID: ${containerId}"
|
||||||
|
|
||||||
run_scripts_in_dir() {
|
run_scripts_in_dir() {
|
||||||
cd "$1"
|
cd "$1"
|
||||||
for script in *.sh; do
|
find . -type f -name '*.sh' -print0 |
|
||||||
echo "> Running Script: $script"
|
while IFS= read -r -d '' file; do
|
||||||
nextcloud_exec "$containerId" "$(< $script)"
|
echo "> Running Script: $file"
|
||||||
|
nextcloud_exec "$containerId" "$(cat $file)" || continue
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ nextcloud_exec_no_shell() {
|
||||||
exec_user="--user $NEXTCLOUD_EXEC_USER"
|
exec_user="--user $NEXTCLOUD_EXEC_USER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec $exec_user -i "$containerId" "$@"
|
docker exec $exec_user "$containerId" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
nextcloud_exec() {
|
nextcloud_exec() {
|
||||||
|
|
Loading…
Reference in a new issue