1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cheky_ynh.git synced 2024-09-03 18:16:00 +02:00

Add helper 'exec_as' and use it

This commit is contained in:
Gofannon 2019-05-08 14:40:34 +02:00
parent 00bcdc08a6
commit 36e152c159
2 changed files with 12 additions and 2 deletions

View file

@ -8,9 +8,18 @@
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
# Taken from https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_read_manifest/ynh_read_manifest_2#L14-L28 # Execute a command as another user
# Idea from https://forum.yunohost.org/t/upgrade-script-how-to-modify-parameter-inside-configuration-file/5352/2 # 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
} }
#================================================= #=================================================

View file

@ -120,6 +120,7 @@ ynh_add_fpm_config
# needs to be edited with latest version # needs to be edited with latest version
# Also avoid to make file "$final_path/version.php" writable # 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 # GENERIC FINALIZATION
#================================================= #=================================================