nextcloud-cronjob/scripts/nextcloud-exec.sh
Robert Dailey faa77b77c8 Support for custom shells
It is now possible to override and explicitly specify the shell you
would like used when executing cron tasks. This is accomplished with the
NEXTCLOUD_EXEC_SHELL environment variable, which defaults to bash. You
can also override and customize the arguments provided to that shell
executable via NEXTCLOUD_EXEC_SHELL_ARGS, which defaults to "-c".

See documentation for more detail and examples.

Fixes #6
2020-08-28 15:23:33 -05:00

18 lines
551 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 -i "$containerId" "$@"
}
nextcloud_exec() {
containerId="$1"; shift
nextcloud_exec_no_shell "$containerId" "$NEXTCLOUD_EXEC_SHELL" $NEXTCLOUD_EXEC_SHELL_ARGS "$@"
}