-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (178 loc) · 6.61 KB
/
Copy pathMakefile
File metadata and controls
210 lines (178 loc) · 6.61 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
VERSION := 1.0.0
INSTALL_DIR := /usr/local/bin
CONFIG_DIR := /etc/wald
COMPLETION_DIR := /etc/bash_completion.d
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
NC := \033[0m
.PHONY: help install uninstall check test clean package
help:
@echo "$(BLUE)WALD CLI - WAL-G + Docker Management Tool$(NC)"
@echo ""
@echo "$(GREEN)Available targets:$(NC)"
@echo " $(YELLOW)install$(NC) - Install WALD CLI system-wide (requires sudo)"
@echo " $(YELLOW)uninstall$(NC) - Remove WALD CLI from system (requires sudo)"
@echo " $(YELLOW)check$(NC) - Check system dependencies"
@echo " $(YELLOW)test$(NC) - Run basic functionality tests"
@echo " $(YELLOW)package$(NC) - Create distribution package"
@echo " $(YELLOW)clean$(NC) - Clean build artifacts"
@echo " $(YELLOW)help$(NC) - Show this help message"
@echo ""
@echo "$(GREEN)Installation:$(NC)"
@echo " make check "
@echo " sudo make install"
@echo ""
@echo "$(GREEN)Usage after install:$(NC)"
@echo " wald config "
@echo " wald backup "
@echo " wald restore "
check:
@echo "$(BLUE)Checking system dependencies...$(NC)"
@echo ""
@if [ ! -f /etc/lsb-release ]; then \
echo "$(RED)❌ This tool is designed for Ubuntu systems$(NC)"; \
exit 1; \
fi
@. /etc/lsb-release && echo "$(GREEN)✅ Ubuntu $$DISTRIB_RELEASE detected$(NC)"
@if command -v docker >/dev/null 2>&1; then \
DOCKER_VERSION=$$(docker --version | cut -d' ' -f3 | cut -d',' -f1); \
echo "$(GREEN)✅ Docker found: v$$DOCKER_VERSION$(NC)"; \
else \
echo "$(RED)❌ Docker not found$(NC)"; \
echo " Install with: curl -fsSL https://get.docker.com | sudo sh"; \
exit 1; \
fi
@if docker compose version >/dev/null 2>&1; then \
COMPOSE_VERSION=$$(docker compose version --short 2>/dev/null || echo "unknown"); \
echo "$(GREEN)✅ Docker Compose found: v$$COMPOSE_VERSION$(NC)"; \
elif command -v docker-compose >/dev/null 2>&1; then \
COMPOSE_VERSION=$$(docker-compose --version | cut -d' ' -f3 | cut -d',' -f1); \
echo "$(GREEN)✅ Docker Compose found: v$$COMPOSE_VERSION$(NC)"; \
else \
echo "$(YELLOW)⚠ Docker Compose not found (recommended for easier setup)$(NC)"; \
fi
@if [ -f "wald" ]; then \
echo "$(GREEN)✅ WALD script found$(NC)"; \
else \
echo "$(RED)❌ WALD script not found in current directory$(NC)"; \
exit 1; \
fi
@echo ""
@echo "$(GREEN)✅ All dependencies satisfied$(NC)"
install: check
@echo "$(BLUE)Installing WALD CLI v$(VERSION)...$(NC)"
@if [ "$$(id -u)" -ne 0 ]; then \
echo "$(RED)❌ Installation requires root privileges$(NC)"; \
echo " Run: sudo make install"; \
exit 1; \
fi
@chmod +x install.sh
@./install.sh
uninstall:
@echo "$(BLUE)Uninstalling WALD CLI...$(NC)"
@if [ "$$(id -u)" -ne 0 ]; then \
echo "$(RED)❌ Uninstallation requires root privileges$(NC)"; \
echo " Run: sudo make uninstall"; \
exit 1; \
fi
@if [ -f "uninstall.sh" ]; then \
chmod +x uninstall.sh; \
./uninstall.sh; \
else \
echo "$(RED)❌ uninstall.sh not found$(NC)"; \
exit 1; \
fi
test:
@echo "$(BLUE)Testing WALD CLI functionality...$(NC)"
@echo ""
@if command -v wald >/dev/null 2>&1; then \
echo "$(GREEN)✅ WALD CLI is installed$(NC)"; \
WALD_VERSION=$$(wald version 2>/dev/null || echo "unknown"); \
echo " Version: $$WALD_VERSION"; \
else \
echo "$(RED)❌ WALD CLI not found$(NC)"; \
echo " Install with: sudo make install"; \
exit 1; \
fi
@if wald help >/dev/null 2>&1; then \
echo "$(GREEN)✅ Help command works$(NC)"; \
else \
echo "$(RED)❌ Help command failed$(NC)"; \
exit 1; \
fi
@if docker info >/dev/null 2>&1; then \
echo "$(GREEN)✅ Docker daemon accessible$(NC)"; \
else \
echo "$(YELLOW)⚠ Docker daemon not accessible (may need to add user to docker group)$(NC)"; \
fi
@if [ -f "$(CONFIG_DIR)/docker-compose.example.yml" ]; then \
echo "$(GREEN)✅ Example configuration available$(NC)"; \
else \
echo "$(YELLOW)⚠ Example configuration not found$(NC)"; \
fi
@if [ -f "$(COMPLETION_DIR)/wald" ]; then \
echo "$(GREEN)✅ Bash completion installed$(NC)"; \
else \
echo "$(YELLOW)⚠ Bash completion not found$(NC)"; \
fi
@echo ""
@echo "$(GREEN)✅ Basic tests completed$(NC)"
package: clean
@echo "$(BLUE)Creating distribution package...$(NC)"
@mkdir -p dist/wald-cli-$(VERSION)
@cp wald dist/wald-cli-$(VERSION)/
@cp install.sh dist/wald-cli-$(VERSION)/
@cp uninstall.sh dist/wald-cli-$(VERSION)/
@cp Makefile dist/wald-cli-$(VERSION)/
@cp README.md dist/wald-cli-$(VERSION)/
@chmod +x dist/wald-cli-$(VERSION)/wald
@chmod +x dist/wald-cli-$(VERSION)/install.sh
@chmod +x dist/wald-cli-$(VERSION)/uninstall.sh
@cd dist && tar -czf wald-cli-$(VERSION).tar.gz wald-cli-$(VERSION)/
@cd dist && zip -r wald-cli-$(VERSION).zip wald-cli-$(VERSION)/ >/dev/null
@echo "$(GREEN)✅ Package created:$(NC)"
@echo " dist/wald-cli-$(VERSION).tar.gz"
@echo " dist/wald-cli-$(VERSION).zip"
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
@rm -rf dist/
@echo "$(GREEN)✅ Clean completed$(NC)"
quick-install:
@echo "$(BLUE)Quick installation from GitHub...$(NC)"
@echo "$(YELLOW)This will download and install WALD CLI$(NC)"
@echo ""
@curl -fsSL https://raw.githubusercontent.com/lafayettegabe/wald-cli/main/install.sh | sudo bash
dev-check:
@echo "$(BLUE)Development checks...$(NC)"
@bash -n wald && echo "$(GREEN)✅ Bash syntax OK$(NC)" || echo "$(RED)❌ Bash syntax error$(NC)"
@bash -n install.sh && echo "$(GREEN)✅ Install script syntax OK$(NC)" || echo "$(RED)❌ Install script syntax error$(NC)"
@bash -n uninstall.sh && echo "$(GREEN)✅ Uninstall script syntax OK$(NC)" || echo "$(RED)❌ Uninstall script syntax error$(NC)"
status:
@echo "$(BLUE)WALD CLI Installation Status$(NC)"
@echo ""
@if [ -f "$(INSTALL_DIR)/wald" ]; then \
echo "$(GREEN)✅ Binary: $(INSTALL_DIR)/wald$(NC)"; \
VERSION_INSTALLED=$$($(INSTALL_DIR)/wald version 2>/dev/null || echo "unknown"); \
echo " Version: $$VERSION_INSTALLED"; \
else \
echo "$(RED)❌ Binary not installed$(NC)"; \
fi
@if [ -f "$(COMPLETION_DIR)/wald" ]; then \
echo "$(GREEN)✅ Bash completion installed$(NC)"; \
else \
echo "$(RED)❌ Bash completion not installed$(NC)"; \
fi
@if [ -d "$(CONFIG_DIR)" ]; then \
echo "$(GREEN)✅ Configuration directory: $(CONFIG_DIR)$(NC)"; \
CONFIG_FILES=$$(ls -1 $(CONFIG_DIR) 2>/dev/null | wc -l); \
echo " Files: $$CONFIG_FILES"; \
else \
echo "$(RED)❌ Configuration directory not found$(NC)"; \
fi
@if command -v wald >/dev/null 2>&1; then \
echo "$(GREEN)✅ Command available in PATH$(NC)"; \
else \
echo "$(RED)❌ Command not available in PATH$(NC)"; \
fi