Introduce kickstart.user.exec

This commit is contained in:
Bruno Tavares
2014-03-03 11:10:03 -03:00
parent 8216d790fa
commit 5f420e6f24
2 changed files with 31 additions and 0 deletions

View File

@ -17,3 +17,16 @@ kickstart.user.remove_group() {
IFS=" " read -a groups < <(id -nG $1 | sed "s/$2//") && \
usermod -G `kickstart.print_with_separator , ${groups[*]}` $1
}
kickstart.user.exec() {
local user=$1
shift
local command=$(cat <<COMMAND
eval "$(kickstart infect)"
$@
COMMAND
)
kickstart.info "Running \"$@\" as $user"
su $user - bash -c "$command"
}