forked from QaidVoid/Complete-Single-GPU-Passthrough
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_hooks.sh
executable file
·45 lines (38 loc) · 1.5 KB
/
install_hooks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
VM_NAME=win10
if [ `whoami` != root ]; then
echo Please run this script as root or using sudo
exit 1
fi
# Create hooks directory and copy qemu script
if test -e /etc/libvirt/ && ! test -e /etc/libvirt/hooks;
then
mkdir -p /etc/libvirt/hooks;
fi
if test -e /etc/libvirt/hooks/qemu;
then
mv /etc/libvirt/hooks/qemu /etc/libvirt/hooks/qemu_last_backup
fi
cp hooks/qemu /etc/libvirt/hooks/qemu
chmod +x /etc/libvirt/hooks/qemu
# Copy start and stop scripts
mkdir -p /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin
if test -e /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin/start.sh;
then
mv /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin/start.sh /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin/start.sh.bk
fi
cp hooks/start.sh /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin/start.sh
chmod +x /etc/libvirt/hooks/qemu.d/${VM_NAME}/prepare/begin/start.sh
mkdir -p /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end
if test -e /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end/stop.sh;
then
mv /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end/stop.sh /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end/stop.sh.bk
fi
cp hooks/start.sh /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end/stop.sh
chmod +x /etc/libvirt/hooks/qemu.d/${VM_NAME}/release/end/stop.sh
# Copy systemd scripts
if test -e /etc/systemd/system/[email protected];
then
rm /etc/systemd/system/[email protected]
fi
cp systemd-no-sleep/[email protected] /etc/systemd/system/[email protected]