mirror of
https://github.com/YunoHost-Apps/aeneria_ynh.git
synced 2024-09-03 18:06:15 +02:00
15 lines
220 B
Text
15 lines
220 B
Text
|
#!/bin/bash
|
||
|
|
||
|
# Execute a command as another user
|
||
|
# usage: exec_as USER COMMAND [ARG ...]
|
||
|
ynh_exec_as() {
|
||
|
local USER=$1
|
||
|
shift 1
|
||
|
|
||
|
if [[ $USER = $(whoami) ]]; then
|
||
|
eval "$@"
|
||
|
else
|
||
|
sudo -u "$USER" "$@"
|
||
|
fi
|
||
|
}
|