upgpkg: wordpress 6.2.1-1
[ArchLinux/community.git] / nextcloud / trunk / nextcloud.occ.sh
blob1cb8cdaff689e63361cbe215089b0d4682cf3cab
1 #!/usr/bin/env bash
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"
8 config=""
9 php_command=""
10 user=""
12 check_sudo() {
13 if ! command -v sudo > /dev/null; then
14 printf "The sudo command is not available.\n"
15 exit 1
19 # allow overriding the php.ini
20 if [[ -n "${NEXTCLOUD_PHP_CONFIG}" ]] && [[ -f "${NEXTCLOUD_PHP_CONFIG}" ]]; then
21 config="${NEXTCLOUD_PHP_CONFIG}"
22 else
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}"
29 else
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}"
36 else
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 "$@"
42 else
43 check_sudo
44 sudo --preserve-env="${preserved_environment_vars}" -u "$user" "$php_command" -c "${config}" /usr/share/webapps/nextcloud/occ "$@"