mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
32 lines
724 B
Bash
32 lines
724 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
#=================================================
|
||
|
# COMMON VARIABLES
|
||
|
#=================================================
|
||
|
|
||
|
#=================================================
|
||
|
# PERSONAL HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
#=================================================
|
||
|
# EXPERIMENTAL HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
#=================================================
|
||
|
# FUTURE OFFICIAL HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
# Execute a command as another user
|
||
|
# usage: ynh_exec_as USER COMMAND [ARG ...]
|
||
|
ynh_exec_as() {
|
||
|
local USER=$1
|
||
|
shift 1
|
||
|
|
||
|
if [[ $USER = $(whoami) ]]; then
|
||
|
eval "$@"
|
||
|
else
|
||
|
sudo -u "$USER" "$@"
|
||
|
fi
|
||
|
}
|
||
|
|