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

16 lines
203 B
Bash
Raw Normal View History

2018-09-03 23:31:52 +02:00
#!/bin/bash
2018-10-07 11:27:33 +02:00
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]
then
eval $@
else
sudo -u "$USER" $@
fi
}