-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (60 loc) · 2.33 KB
/
Makefile
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
APP_NAME := alafia-fsl
HOST_NAME := #none
HOST_IP := #none
DOCKER_PLATFORM := linux/amd64
DOCKER_IMAGE_NAME := $(APP_NAME)
DOCKER_IMAGE_TAG := latest
DOCKER_CONTEXT := ./build
DOCKERFILE := ./build/Dockerfile
DEPLOY_PATH := ./deploy
SERVICE_FILE := #none
DESKTOP_FILE := $(APP_NAME).desktop
APPLICATIONS_DIR := /usr/share/applications
MODIFYHOSTS_SCRIPT := ../modify-hosts.sh
# Build the Docker image
build:
@echo "Building Docker image..."
docker build --platform=$(DOCKER_PLATFORM) --no-cache -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) -f $(DOCKERFILE) $(DOCKER_CONTEXT)
@echo "Docker image built successfully."
# Install the systemd service
install:
@echo "Installing desktop entry..."
sudo cp $(DEPLOY_PATH)/$(DESKTOP_FILE) $(APPLICATIONS_DIR)
@echo "Desktop entry installed successfully."
@if [ -z "$(SERVICE_FILE)" ]; then \
echo "SERVICE_FILE is not set. Skipping Systemd modification."; \
else \
echo "Installing systemd service..." && \
sudo cp $(DEPLOY_PATH)/$(SERVICE_FILE) /etc/systemd/system/ && \
sudo systemctl enable $(SERVICE_FILE) && \
echo "Systemd service installed and started successfully."; \
fi
@if [ -z "$(HOST_NAME)" ]; then \
echo "HOST_NAME is not set. Skipping hosts modification."; \
else \
echo "Adding entry to /etc/hosts..." && \
sudo $(MODIFYHOSTS_SCRIPT) $(HOST_IP) $(HOST_NAME) add && \
echo "Entry added to /etc/hosts successfully."; \
fi
# Uninstall the systemd service and remove all installed files
uninstall:
@echo "Removing desktop entry..."
sudo rm -f $(APPLICATIONS_DIR)/$(DESKTOP_FILE)
@echo "Desktop entry removed successfully."
@if [ -z "$(SERVICE_FILE)" ]; then \
echo "SERVICE_FILE is not set. Skipping Systemd modification."; \
else \
echo "Stopping and disabling systemd service..." && \
sudo systemctl stop $(SERVICE_FILE) && \
sudo systemctl disable $(SERVICE_FILE) && \
sudo rm -f /etc/systemd/system/$(SERVICE_FILE) && \
echo "Systemd service stopped, disabled, and removed successfully."; \
fi
@if [ -z "$(HOST_NAME)" ]; then \
echo "HOST_NAME is not set. Skipping hosts modification."; \
else \
echo "Removing entry from /etc/hosts..." && \
sudo $(MODIFYHOSTS_SCRIPT) $(HOST_IP) $(HOST_NAME) remove && \
echo "Entry removed from /etc/hosts successfully."; \
fi
.PHONY: build install uninstall