1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cryptpad_ynh.git synced 2024-09-03 18:26:14 +02:00

Update _common.sh

This commit is contained in:
frju365 2018-05-04 11:29:29 +02:00 committed by GitHub
parent bf1cec2861
commit 47f62c9994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -173,3 +173,26 @@ EOF
chmod +x "/etc/cron.daily/node_update" chmod +x "/etc/cron.daily/node_update"
} }
# EXEC_LOGIN_AS Helper
# Execute a command as another user with login
# (hence in user home dir, with prior loading of .profile, etc.)
# usage: exec_login_as USER COMMAND [ARG ...]
exec_login_as() {
local user=$1
shift 1
exec_as $user --login "$@"
}
# 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
}