New scripts and sudo rules. Implement qemu session mode.
This commit is contained in:
parent
91aab8e75b
commit
7871936a67
19 changed files with 176 additions and 67 deletions
28
roles/lmn_vm/files/start-virtiofsd.sh
Executable file
28
roles/lmn_vm/files/start-virtiofsd.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# if less than one arguments supplied, display usage
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "This script takes as input the name of the VM " >&2
|
||||
echo "Usage: $0 vm_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VM_NAME=$1
|
||||
|
||||
export XDG_RUNTIME_DIR="/run/user/${SUDO_UID}"
|
||||
|
||||
if ! [[ -d "${XDG_RUNTIME_DIR}/virtiofs" ]]; then
|
||||
mkdir "${XDG_RUNTIME_DIR}/virtiofs/"
|
||||
chown "${SUDO_UID}" "${XDG_RUNTIME_DIR}/virtiofs/"
|
||||
fi
|
||||
|
||||
[[ -S "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" ]] && /usr/bin/rm "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" --socket-group="${SUDO_USER}" --announce-submounts -o source="/media/${USER}" -o sandbox=chroot > /dev/null &
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" --socket-group="${SUDO_USER}" -o source="/media/${USER}" -o sandbox=chroot > /dev/null &
|
||||
/usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" -o source="/media/${SUDO_USER}" -o sandbox=chroot > /dev/null &
|
||||
# Wait until socket-File exists and chown to user
|
||||
until [[ -S "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" ]]; do
|
||||
echo "waiting for ${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
sleep 0.1
|
||||
done
|
||||
/usr/bin/chown "${SUDO_USER}" "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
Loading…
Add table
Add a link
Reference in a new issue