From 8ca44dfab35cdeaf7ad3b69438c8256fb5f3431c Mon Sep 17 00:00:00 2001 From: fedir Date: Thu, 22 May 2025 11:02:47 +0200 Subject: [PATCH] Added install rule to Makefile --- Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e87933a..8fa53c8 100644 --- a/Makefile +++ b/Makefile @@ -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 +