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

28 lines
682 B
Bash
Raw Normal View History

2018-05-05 17:03:04 +02:00
#!/bin/bash
2019-03-04 23:53:39 +01:00
#=================================================
# PERSONAL HELPERS
#=================================================
2019-03-04 23:53:39 +01:00
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
2019-05-08 14:40:34 +02:00
# 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
2019-05-08 14:40:34 +02:00
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}
2019-03-04 23:53:39 +01:00
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================