diff --git a/scripts/_common.sh b/scripts/_common.sh index f0851b0..c85fc0e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,9 +8,18 @@ # EXPERIMENTAL HELPERS #================================================= -# Taken from https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_read_manifest/ynh_read_manifest_2#L14-L28 -# Idea from https://forum.yunohost.org/t/upgrade-script-how-to-modify-parameter-inside-configuration-file/5352/2 +# Execute a command as another user +# usage: exec_as USER COMMAND [ARG ...] +# Source : https://github.com/YunoHost-Apps/Experimental_helpers/tree/master/ynh_exec_as +exec_as() { + local USER=$1 + shift 1 + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi } #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f35a96b..4bf48eb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -120,6 +120,7 @@ ynh_add_fpm_config # needs to be edited with latest version # Also avoid to make file "$final_path/version.php" writable +#exec_as "$app" "/usr/bin/php $YNH_CWD/upgrade_cheky.php $final_path" #================================================= # GENERIC FINALIZATION #=================================================