mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
12 lines
203 B
Bash
12 lines
203 B
Bash
# 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
|
|
}
|