2020-07-27 14:56:37 +00:00
|
|
|
all: superfans-gpu-controller superfans-gpu-controller.service
|
|
|
|
.PHONY: all superfans-gpu-controller-daemon install uninstall clean
|
|
|
|
|
|
|
|
service_dir=/etc/systemd/system
|
|
|
|
conf_dir=/etc
|
|
|
|
awk_script='BEGIN {FS="="; OFS="="}{if ($$1=="ExecStart") {$$2=exec_path} if (substr($$1,1,1) != "\#") {print $$0}}'
|
|
|
|
|
2020-07-27 16:17:11 +00:00
|
|
|
src_python_dir=python
|
2020-07-27 14:56:37 +00:00
|
|
|
|
2020-07-27 16:17:11 +00:00
|
|
|
superfans-gpu-controller: $(src_python_dir)/superfans_gpu_controller.py $(src_python_dir)/setup.py
|
|
|
|
pip3 install $(src_python_dir)/.
|
|
|
|
|
2020-07-28 12:25:40 +00:00
|
|
|
superfans-gpu-controller.service: $(src_python_dir)/superfans_gpu_controller.py superfans-gpu-controller
|
2020-07-27 14:56:37 +00:00
|
|
|
# awk is needed to replace the absolute path of mydaemon executable in the .service file
|
2020-07-27 16:17:11 +00:00
|
|
|
awk -v exec_path='$(shell which superfans-gpu-controller) $(conf_dir)/superfans-gpu-controller.json' $(awk_script) etc/systemd/system/superfans-gpu-controller.service.template > etc/systemd/system/superfans-gpu-controller.service
|
2020-07-27 14:56:37 +00:00
|
|
|
|
2020-07-28 12:25:40 +00:00
|
|
|
install: $(service_dir) $(conf_dir) superfans-gpu-controller.service
|
2020-07-27 16:17:11 +00:00
|
|
|
cp etc/superfans-gpu-controller.json $(conf_dir)
|
|
|
|
cp etc/systemd/system/superfans-gpu-controller.service $(service_dir)
|
2020-07-27 14:56:37 +00:00
|
|
|
-systemctl enable superfans-gpu-controller.service
|
|
|
|
-systemctl enable superfans-gpu-controller
|
2020-07-27 16:25:40 +00:00
|
|
|
-systemctl start superfans-gpu-controller
|
2020-07-27 14:56:37 +00:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
-systemctl stop superfans-gpu-controller
|
2020-07-28 12:25:40 +00:00
|
|
|
-systemctl disable superfans-gpu-controller
|
2020-07-27 14:56:37 +00:00
|
|
|
-rm -r $(service_dir)/superfans-gpu-controller.service
|
|
|
|
-rm -r $(conf_dir)/superfans-gpu-controller.json
|
2020-07-28 12:25:40 +00:00
|
|
|
-systemctl daemon-reload
|
|
|
|
-systemctl reset-failed
|
|
|
|
pip3 uninstall -y superfans-gpu-controller
|
|
|
|
|
2020-07-27 14:56:37 +00:00
|
|
|
clean:
|
2020-07-27 16:17:11 +00:00
|
|
|
-rm etc/systemd/system/superfans-gpu-controller.service
|