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:
parent
00bcdc08a6
commit
36e152c159
2 changed files with 12 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue