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
2019-05-08 14:40:34 +02:00

27 lines
682 B
Bash

#!/bin/bash
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# 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
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================