feat: check for requirements and try to install via pacman if missing

This commit is contained in:
Daniel Langbein 2023-03-28 17:49:31 +02:00
parent 88596cbd46
commit f68e371c7c

View File

@ -4,13 +4,21 @@ PKGNAME := netcup-dns
all: install all: install
.PHONY: install .PHONY: install
install: notify cron install: nc-dnsapi requests notify cron
sudo python3 -m pip install --upgrade --force-reinstall . sudo python3 -m pip install --upgrade --force-reinstall .
sudo install -m0644 cron.d/$(PKGNAME) /etc/cron.d/$(PKGNAME) sudo install -m0644 cron.d/$(PKGNAME) /etc/cron.d/$(PKGNAME)
sudo install --directory -m755 /etc/$(PKGNAME)/ sudo install --directory -m755 /etc/$(PKGNAME)/
sudo install -m0644 cfg/* /etc/$(PKGNAME)/ sudo install -m0644 cfg/* /etc/$(PKGNAME)/
.PHONY: nc-dnsapi ## Check if nc-dnsapi is installed.
nc-dnsapi:
pip list | cut -f 1 -d ' ' | grep '^nc-dnsapi$$' || sudo pacman -S --needed python-nc-dnsapi
.PHONY: requests ## Check if requests is installed.
requests:
pip list | cut -f 1 -d ' ' | grep '^requests$$' || sudo pacman -S --needed python-requests
.PHONY: notify ## Check if execNotify is installed. .PHONY: notify ## Check if execNotify is installed.
notify: notify:
# `type` does not work e.g. on Ubuntu 18.04 # `type` does not work e.g. on Ubuntu 18.04
@ -26,4 +34,4 @@ cron:
.PHONY: clean .PHONY: clean
clean: clean:
sudo python3 -m pip uninstall -y $(PKGNAME) sudo python3 -m pip uninstall -y $(PKGNAME)
rm -rf /etc/cron.d/$(PKGNAME) /etc/$(PKGNAME) sudo rm -rf /etc/cron.d/$(PKGNAME) /etc/$(PKGNAME)