-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
165 lines (145 loc) Β· 4.12 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
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
#@author Fred Brooker <[email protected]>
include .env
run ?=
db_status != docker inspect --format '{{json .State.Running}}' ${UMAMI_DB_CONTAINER_NAME} 2>/dev/null | grep true
um_status != docker inspect --format '{{json .State.Running}}' ${UMAMI_CONTAINER_NAME} 2>/dev/null | grep true
umdb_status := $(um_status)$(db_status)
umdbok = truetrue
ifneq ($(strip $(um_status)),)
umdot=π’
else
umdot=π΄
endif
ifneq ($(strip $(db_status)),)
dbdot=π’
else
dbdot=π΄
endif
all: info
info:
@echo "\n\e[1;32mUmami in Docker πΎ\e[0m v1.11 2024-12-18\n"
@echo "\e[0;1mπ¦οΈ UMAMI\e[0m \t $(umdot) \e[0;4m${UMAMI_CONTAINER_NAME}\e[0m \tπ http://localhost:${UMAMI_PORT}"
@echo "\e[0;1mπ¦οΈ DB\e[0m \t\t $(dbdot) \e[0;4m${UMAMI_DB_CONTAINER_NAME}\e[0m"
@echo ""
@echo " - \e[0;1m install\e[0m - install containers"
@echo " - \e[0;1m start\e[0m - start containers"
@echo " - \e[0;1m stop\e[0m - stop containers"
@echo " - \e[0;1m test\e[0m - test containers"
@echo " - \e[0;1m kill\e[0m - kill containers"
@echo " - \e[0;1m remove\e[0m - remove containers"
@echo " - \e[0;1m backup\e[0m - backup database"
@echo " - \e[0;1m restore\e[0m - restore database"
@echo " - \e[0;1m exec\e[0m - run interactive shell"
@echo " - \e[0;1m exec run='<command>'\e[0m - run <command> in shell"
@echo " - \e[0;1m debug\e[0m - run interactively"
@echo " - \e[0;1m config\e[0m - display configuration"
@echo " - \e[0;1m logs\e[0m - display logs"
@echo " - \e[0;1m purge\e[0m - delete persistent data βοΈ"
@echo " - \e[0;1m docs\e[0m - transpile documentation into PDF"
@echo ""
docs:
@find . -maxdepth 1 -iname "*.md" -exec echo "converting {} to ADOC" \; -exec docker run --rm -v "$$(pwd)":/data pandoc/core -f markdown -t asciidoc -i "{}" -o "{}.adoc" \;
@find . -maxdepth 1 -iname "*.adoc" -exec echo "converting {} to PDF" \; -exec docker run --rm -v $$(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf -a allow-uri-read -d book "{}" \;
@find . -maxdepth 1 -iname "*.adoc" -delete
debug:
@docker compose up
install: remove
@date
@echo "installing containers"
@docker compose up -d
@echo "\n\e[0;1mπ¦οΈ Umami\e[0m: π http://localhost:${UMAMI_PORT}\n"
@date
start:
@echo "starting containers"
@docker start ${UMAMI_CONTAINER_NAME}
@docker start ${UMAMI_DB_CONTAINER_NAME}
stop:
@echo "stopping containers"
@-docker stop ${UMAMI_CONTAINER_NAME}
@-docker stop ${UMAMI_DB_CONTAINER_NAME}
kill:
@echo "π΅"
@docker compose kill
remove:
@echo "removing containers"
@-docker rm ${UMAMI_CONTAINER_NAME} --force 2>/dev/null
@-docker rm ${UMAMI_DB_CONTAINER_NAME} --force 2>/dev/null
config:
@docker compose config
exec:
ifneq ($(strip $(run)),)
@docker exec ${UMAMI_CONTAINER_NAME} $(run)
else
@docker exec -it ${UMAMI_CONTAINER_NAME} sh
endif
logs:
@docker logs -f ${UMAMI_CONTAINER_NAME}
backup:
ifneq ($(shell id -u),0)
@echo "root permission required"
@sudo echo ""
endif
@date
@docker compose down
@rm -rf bak
@mkdir bak
ifneq ($(shell id -u),0)
@echo "root permission required"
endif
@sudo tar czf bak/umami-db-data.tgz umami-db-data
@cp Makefile bak/
@cp .env bak/
@cp docker-compose.yml bak/
@-make install
@date
restore: remove
ifneq ($(shell id -u),0)
@echo "root permission required"
@sudo echo ""
endif
@date
ifneq ($(shell id -u),0)
@echo "root permission required"
endif
@sudo rm -rf umami-db-data
ifneq ($(wildcard ./bak/.),)
@echo "backup location: bak"
ifneq ($(wildcard bak/umami-db-data.tgz),)
@-sudo tar xzf bak/umami-db-data.tgz 2>/dev/null
else
@echo "βοΈ missing database archive"
exit 1
endif
else
@echo "backup location: ."
ifneq ($(wildcard umami-db-data.tgz),)
@-sudo tar xzf umami-db-data.tgz 2>/dev/null
else
@echo "βοΈ missing database archive"
exit 1
endif
endif
@-make install
@date
purge: remove
@echo "π deleting permanent storage"
ifneq ($(shell id -u),0)
@echo "root permission required"
endif
sudo rm -rf umami-db-data
test:
ifneq ($(strip $(um_status)),)
@echo "π’ Umami is up"
else
@echo "π΄ Umami is down"
endif
ifneq ($(strip $(db_status)),)
@echo "π’ DB is up"
else
@echo "π΄ DB is down"
endif
ifneq ($(umdb_status), $(umdbok))
@exit 255
else
@exit 0
endif