From fd04753b75655af4ca796cb5fa4cb5b19689625c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 27 May 2021 11:35:42 +0200 Subject: [PATCH] Use ynh_exec_as --- scripts/_common.sh | 15 --------------- scripts/change_url | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ca742ee..c4e3403 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,21 +12,6 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} - -#================================================= - # Check if an URL is already handled # usage: is_url_handled --domain=DOMAIN --path=PATH_URI is_url_handled() { diff --git a/scripts/change_url b/scripts/change_url index f89e12e..5c6deb8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -101,7 +101,7 @@ ynh_script_progression --message="Applying Nextcloud specific modifications..." # Define a function to execute commands with `occ` exec_occ() { - (cd "$final_path" && exec_as "$app" \ + (cd "$final_path" && ynh_exec_as "$app" \ php${phpversion} occ --no-interaction --no-ansi "$@") } diff --git a/scripts/install b/scripts/install index 614c496..bb5e844 100755 --- a/scripts/install +++ b/scripts/install @@ -142,7 +142,7 @@ ynh_script_progression --message="Installing Nextcloud..." --weight=30 # Define a function to execute commands with `occ` exec_occ() { - (cd "$final_path" && exec_as "$app" \ + (cd "$final_path" && ynh_exec_as "$app" \ php${phpversion} occ --no-interaction --no-ansi "$@") } diff --git a/scripts/upgrade b/scripts/upgrade index a9ed1c6..39b124d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -193,7 +193,7 @@ exec_occ() { else NEXTCLOUD_PHP_VERSION="7.0" fi -(cd "$final_path" && exec_as "$app" \ +(cd "$final_path" && ynh_exec_as "$app" \ php$NEXTCLOUD_PHP_VERSION occ --no-interaction --no-ansi "$@") }