nextcloud-cronjob/scripts/nextcloud-exec.sh
Robert Dailey f2ce54653b 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.
2020-10-27 16:48:34 -05:00

18 lines
548 B
Bash

#!/usr/bin/env bash
nextcloud_exec_no_shell() {
containerId="$1"; shift
# 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
docker exec $exec_user "$containerId" "$@"
}
nextcloud_exec() {
containerId="$1"; shift
nextcloud_exec_no_shell "$containerId" "$NEXTCLOUD_EXEC_SHELL" $NEXTCLOUD_EXEC_SHELL_ARGS "$@"
}