Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
scripts: Run QEMU as normal user
Browse files Browse the repository at this point in the history
To run QEMU as normal user, we store the files in the appropriate
user directory (if available).

Signed-off-by: George Hopkins <[email protected]>
  • Loading branch information
george-hopkins committed Feb 8, 2022
1 parent a8ac3e3 commit 19d8101
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions scripts/qemu-guest
Original file line number Diff line number Diff line change
Expand Up @@ -339,28 +339,15 @@ _ideid_2_unit()
printf '%d' "$UNIT"
}

##
## ARE WE ROOT?
##
if [ $( id -u ) != 0 ]; then
if [ -x $( which sudo ) ]; then
echo "Trying to get root privileges..." 1>&2
exec sudo "$0" "$@"
exit 2
fi

echo "Please run as root" 1>&2
exit 1
fi

##
## MAIN
##
QEMU_BASE_ARGS=()
QEMU_ARGS=()
SOCK_MONITOR="/run/$( basename "$0" )-$$_monitor.socket"
SOCK_SERIAL="/run/$( basename "$0" )-$$_serial.socket"
PIDFILE="/run/$( basename "$0" )-$$_qemu.pid"
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run}"
SOCK_MONITOR="$RUNTIME_DIR/$( basename "$0" )-$$_monitor.socket"
SOCK_SERIAL="$RUNTIME_DIR/$( basename "$0" )-$$_serial.socket"
PIDFILE="$RUNTIME_DIR/$( basename "$0" )-$$_qemu.pid"
TEMP="/tmp/$( basename "$0" )-$$"

ARG_MACHINETYPE="x86pc"
Expand Down

0 comments on commit 19d8101

Please sign in to comment.