-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (30 loc) · 1.27 KB
/
Makefile
File metadata and controls
41 lines (30 loc) · 1.27 KB
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
all:
@echo "Compiling the program..."
gcc daemon.c -lvirt -o daemon
install: all
@echo ""
@grep -Fq 'Environment="VFIO_VM_NAME=' vfio-vm-rotation.service || \
(echo 'ERROR: Please set `VFIO_VM_NAME` environment variable in vfio-vm-rotation.service, then try again.' && exit 1)
@grep -Fq 'Environment="IDLE_VM_NAME=' vfio-vm-rotation.service || \
(echo 'ERROR: Please set `IDLE_VM_NAME` environment variable in vfio-vm-rotation.service, then try again.' && exit 1)
@echo "Disable the service if it already exists..."
ifneq ("$(wildcard /etc/systemd/system/vfio-vm-rotation.service)","")
systemctl disable --now vfio-vm-rotation
endif
@echo "" ; echo "Installing the binary..."
mkdir -p /opt/vfio-vm-rotation/
cp daemon /opt/vfio-vm-rotation/
chmod u+x /opt/vfio-vm-rotation/daemon
@echo "" ; echo "Installing the systemd service..."
cp vfio-vm-rotation.service /etc/systemd/system
systemctl enable --now vfio-vm-rotation
@echo "" ; echo "Cleaning up..."
rm daemon
@echo "" ; echo "Installation finished!"
uninstall:
@echo "Disabling and deleting the service..."
systemctl disable --now vfio-vm-rotation
rm -f /etc/systemd/system/vfio-vm-rotation.service
@echo "" ; echo "Deleting the binary..."
rm -rf /opt/vfio-vm-rotation
@echo "" ; echo "Uninstallation finished!"