Added install rule to Makefile

This commit is contained in:
fedir 2025-05-22 11:02:47 +02:00
parent 1b53a9638e
commit 8ca44dfab3
Signed by: fedir
GPG Key ID: C959EE85F0C9362C

View File

@ -65,7 +65,7 @@ endif
default: $(TARGETS)
.PHONY: clean icfs_test clean-icfs clean-icfs_dialogue
.PHONY: clean icfs_test clean-icfs clean-icfs_dialogue install uninstall
$(BUILD_DIR)/icfs_dialogue:
make -C $(SOURCES_DIR)/gui TEST=$(TEST) DEBUG=$(shell realpath $(DEBUG)) SOURCES_DIR=$(shell realpath $(SOURCES_DIR)/gui) BUILD_DIR=$(shell realpath $(BUILD_DIR)) TESTS_DIR=$(shell realpath $(TESTS_DIR))
@ -113,3 +113,19 @@ clean-icfs:
clean-icfs_dialogue:
make -C $(SOURCES_DIR)/gui clean SOURCES_DIR=$(shell realpath $(SOURCES_DIR)/gui) BUILD_DIR=$(shell realpath $(BUILD_DIR)) TESTS_DIR=$(shell realpath $(TESTS_DIR))
install: $(BUILD_DIR)/icfs $(BUILD_DIR)/icfs_dialogue
@echo "Install script needs superuser permission to:"
@printf "\t1. Move executables to /usr/bin.\n"
@printf "\t2. Create \"icfs\" user.\n"
@printf "\t3. Set the setuid bit of icfs executable.\n"
sudo cp $(BUILD_DIR)/icfs /usr/bin/icfs && sudo cp $(BUILD_DIR)/icfs_dialogue /usr/bin/icfs_dialogue
id -u icfs &>/dev/null || sudo useradd --system --user-group icfs
sudo chown icfs: /usr/bin/icfs && sudo chmod 4777 /usr/bin/icfs
@read -p "Create /etc/icfs directory for permission databases [y/N]: " permd; if [[ $$permd == "y" ]]; then echo "sudo mkdir /etc/icfs && sudo chown :icfs /etc/icfs && sudo chmod g+rw,o= /etc/icfs;"; sudo mkdir /etc/icfs && sudo chown icfs:icfs /etc/icfs && sudo chmod g+rw,o= /etc/icfs; fi
uninstall:
@echo "Install script needs superuser permission to remove executables in /usr/bin"
sudo rm -f /usr/bin/icfs /usr/bin/icfs_dialogue
@read -p "Remove /etc/icfs directory [y/N]: " permd; if [[ $$permd == "y" ]]; then echo "sudo rm -rf /etc/icfs"; sudo rm -rf /etc/icfs; fi