-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (63 loc) · 2.19 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
69
70
71
72
.PHONY: all clean build install check-env setup-shell
SHELL := /bin/bash
HOME_BIN := $(HOME)/bin
CONFIG_DIR := $(HOME)/.config/dockforward
all: build
build:
@echo "Building dockforward..."
@go build -o bin/dockforward-monitor
@go build -o bin/dockforward cmd/docker/main.go
clean:
rm -rf bin/
check-env:
@echo "Checking environment..."
@if [ ! -d "$(HOME_BIN)" ]; then \
echo "Creating $(HOME_BIN)..."; \
mkdir -p $(HOME_BIN); \
fi
@if [ ! -d "$(CONFIG_DIR)" ]; then \
echo "Creating config directory..."; \
mkdir -p $(CONFIG_DIR); \
fi
setup-shell:
@echo "Setting up shell configuration..."
@SHELL_NAME=$$(basename $$SHELL); \
if [ "$$SHELL_NAME" = "zsh" ]; then \
PROFILE="$(HOME)/.zshrc"; \
else \
PROFILE="$(HOME)/.bashrc"; \
fi; \
if ! grep -q "PATH=.*$(HOME_BIN)" "$$PROFILE"; then \
echo 'export PATH="$(HOME_BIN):$$PATH"' >> "$$PROFILE"; \
echo "Added $(HOME_BIN) to PATH in $$PROFILE"; \
fi
install: check-env build setup-shell
@echo "Installing dockforward..."
@if command -v docker > /dev/null; then \
echo "Docker is already installed."; \
echo "Installing as 'dockforward'..."; \
cp bin/dockforward-monitor $(HOME_BIN)/; \
cp bin/dockforward $(HOME_BIN)/; \
echo "Installation complete. Run 'dockforward-monitor' to configure and start."; \
else \
read -p "Docker is not installed. Would you like to install dockforward as the 'docker' command? [Y/n] " choice; \
case "$$choice" in \
n|N) echo "Installing as 'dockforward'..."; \
cp bin/dockforward-monitor $(HOME_BIN)/; \
cp bin/dockforward $(HOME_BIN)/; \
echo "Installation complete. Run 'dockforward-monitor' to configure and start.";; \
*) echo "Installing as 'docker'..."; \
cp bin/dockforward-monitor $(HOME_BIN)/docker-monitor; \
cp bin/dockforward $(HOME_BIN)/docker; \
echo "Installation complete. Run 'docker-monitor' to configure and start.";; \
esac \
fi
@echo "Please run: source ~/.zshrc (or ~/.bashrc for bash users)"
uninstall:
@echo "Uninstalling dockforward..."
rm -f $(HOME_BIN)/dockforward-monitor
rm -f $(HOME_BIN)/dockforward
rm -f $(HOME_BIN)/docker-monitor
rm -f $(HOME_BIN)/docker
@echo "Uninstallation complete"
reinstall: uninstall install