diff --git a/bin/qemush b/bin/qemush index cd360c1..754eee4 100755 --- a/bin/qemush +++ b/bin/qemush @@ -1,10 +1,18 @@ #!/bin/bash -if [ "$(whoami)" != root ]; then - exec sudo -u qemu "$0" "$@" -else - cd || exit -fi +exec_as() { + local user + user="$1" + shift + + if [ "$(whoami)" != "$user" ]; then + exec sudo -u "$user" "$0" "$@" + else + cd || exit + fi +} + +exec_as qemu "$@" bin=bin images=images