mirror of
https://github.com/nextcloud/docker.git
synced 2025-02-06 03:18:26 +01:00
Add occ
and occ-cron
scripts
This allows easier access to `occ` and `occ-cron` within the container. Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
This commit is contained in:
parent
65138b6d22
commit
d3b7a6483d
5 changed files with 41 additions and 5 deletions
|
@ -142,7 +142,8 @@ RUN set -ex; \
|
|||
chmod +x /usr/src/nextcloud/occ; \
|
||||
apk del --no-network .fetch-deps
|
||||
|
||||
COPY *.sh upgrade.exclude /
|
||||
COPY entrypoint.sh cron.sh upgrade.exclude /
|
||||
COPY occ occ-cron /usr/local/bin/
|
||||
COPY config/* /usr/src/nextcloud/config/
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
@ -151,7 +151,8 @@ RUN set -ex; \
|
|||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY *.sh upgrade.exclude /
|
||||
COPY entrypoint.sh cron.sh upgrade.exclude /
|
||||
COPY occ occ-cron /usr/local/bin/
|
||||
COPY config/* /usr/src/nextcloud/config/
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
19
docker-occ-cron.sh
Executable file
19
docker-occ-cron.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ "$(occ status 2> /dev/null | sed -ne 's/^ - installed: \(.*\)$/\1/p')" != "true" ]; then
|
||||
echo "Nextcloud is not installed - cronjobs are not available" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -e /var/www/html/cron.php ] || { echo "Unable to run \`occ-cron\`: No such file or directory" >&2 ; exit 1 ; }
|
||||
[ -f /var/www/html/cron.php ] || { echo "Unable to run \`occ-cron\`: Not a file" >&2 ; exit 1 ; }
|
||||
|
||||
RUN_AS="$(stat -c %U /var/www/html/cron.php)"
|
||||
[ -n "$RUN_AS" ] && [ "$RUN_AS" != "UNKNOWN" ] || { echo "Unable to run \`occ-cron\`: Failed to determine www-data user" >&2 ; exit 1 ; }
|
||||
|
||||
if [ "$(id -u)" == 0 ]; then
|
||||
exec su -p "$RUN_AS" -s /bin/sh -c 'php -f /var/www/html/cron.php' -- '/bin/sh'
|
||||
else
|
||||
exec php -f /var/www/html/cron.php
|
||||
fi
|
14
docker-occ.sh
Executable file
14
docker-occ.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
[ -e /var/www/html/occ ] || { echo "Unable to run \`occ\`: No such file or directory" >&2 ; exit 1 ; }
|
||||
[ -f /var/www/html/occ ] || { echo "Unable to run \`occ\`: Not a file" >&2 ; exit 1 ; }
|
||||
|
||||
RUN_AS="$(stat -c %U /var/www/html/occ)"
|
||||
[ -n "$RUN_AS" ] && [ "$RUN_AS" != "UNKNOWN" ] || { echo "Unable to run \`occ\`: Failed to determine www-data user" >&2 ; exit 1 ; }
|
||||
|
||||
if [ "$(id -u)" == 0 ]; then
|
||||
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/occ -- "$@"' -- '/bin/sh' "$@"
|
||||
else
|
||||
exec php -f /var/www/html/occ -- "$@"
|
||||
fi
|
|
@ -128,9 +128,10 @@ function create_variant() {
|
|||
' "$dir/Dockerfile"
|
||||
|
||||
# Copy the shell scripts
|
||||
for name in entrypoint cron; do
|
||||
cp "docker-$name.sh" "$dir/$name.sh"
|
||||
done
|
||||
cp "docker-entrypoint.sh" "$dir/entrypoint.sh"
|
||||
cp "docker-cron.sh" "$dir/cron.sh"
|
||||
cp "docker-occ.sh" "$dir/occ"
|
||||
cp "docker-occ-cron.sh" "$dir/occ-cron"
|
||||
|
||||
# Copy the upgrade.exclude
|
||||
cp upgrade.exclude "$dir/"
|
||||
|
|
Loading…
Reference in a new issue