Skip to content

Commit

Permalink
Fix POSIX shell differences of Alpine and Debian in occ and occ-cron
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Rudolf <[email protected]>
  • Loading branch information
PhrozenByte committed Dec 15, 2023
1 parent a084db4 commit 512dcf2
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 26/apache/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 26/fpm-alpine/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 26/fpm/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 27/apache/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 27/fpm-alpine/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 27/fpm/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 28/apache/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 28/fpm-alpine/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion 28/fpm/occ-cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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'
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
4 changes: 2 additions & 2 deletions docker-occ-cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fi
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'
if [ "$(id -u)" = 0 ]; then
exec su -p "$RUN_AS" -s /bin/sh -c 'exec php -f /var/www/html/cron.php' -- '/bin/sh'
else
exec php -f /var/www/html/cron.php
fi
2 changes: 1 addition & 1 deletion docker-occ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -eu
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
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 -- "$@"
Expand Down

0 comments on commit 512dcf2

Please sign in to comment.