3 readonly default_config
="/etc/php-legacy/php.ini"
4 readonly default_php_command
="/usr/bin/php-legacy"
5 readonly default_user
="nextcloud"
6 readonly preserved_environment_vars
="NEXTCLOUD_CONFIG_DIR"
13 if ! command -v sudo
> /dev
/null
; then
14 printf "The sudo command is not available.\n"
19 # allow overriding the php.ini
20 if [[ -n "${NEXTCLOUD_PHP_CONFIG}" ]] && [[ -f "${NEXTCLOUD_PHP_CONFIG}" ]]; then
21 config
="${NEXTCLOUD_PHP_CONFIG}"
23 config
="${default_config}"
26 # allow overriding the php executable
27 if [[ -n "${NEXTCLOUD_PHP}" ]] && command -v "${NEXTCLOUD_PHP}" > /dev
/null
; then
28 php_command
="${NEXTCLOUD_PHP}"
30 php_command
="${default_php_command}"
33 # allow overriding the user to run as
34 if [[ -n "${NEXTCLOUD_USER}" ]] && id
"${NEXTCLOUD_USER}" > /dev
/null
2>&1; then
35 user
="${NEXTCLOUD_USER}"
37 user
="${default_user}"
40 if [[ "${UID}" -eq 0 ]]; then
41 runuser
--whitelist-environment="${preserved_environment_vars}" -u "$user" -- "$php_command" -c "${config}" /usr
/share
/webapps
/nextcloud
/occ
"$@"
44 sudo
--preserve-env="${preserved_environment_vars}" -u "$user" "$php_command" -c "${config}" /usr
/share
/webapps
/nextcloud
/occ
"$@"