-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
289 lines (204 loc) · 5.57 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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
COMPOSE_PROJECT_NAME = nextcloud-gfarm
ENV_FILE = --env-file config.env
SUDO = $(shell docker version > /dev/null 2>&1 || echo sudo)
DOCKER = $(SUDO) docker
COMPOSE_V1 = docker-compose
COMPOSE_V2 = docker compose
COMPOSE_SW = $(shell ${COMPOSE_V2} version > /dev/null 2>&1 && echo ${COMPOSE_V2} || echo ${COMPOSE_V1})
COMPOSE = $(SUDO) COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) $(COMPOSE_SW) $(ENV_FILE)
EXEC_COMMON_USER = $(COMPOSE) exec -u www-data
EXEC_COMMON_ROOT = $(COMPOSE) exec -u root
EXEC = $(EXEC_COMMON_USER) nextcloud
EXEC_ROOT = $(EXEC_COMMON_ROOT) nextcloud
OCC = $(EXEC) php /var/www/html/occ
SHELL=/bin/bash
# use selfsigned certificate
SSC_COMPOSE = $(COMPOSE) -f docker-compose.selfsigned.yml
CONTAINERS = nextcloud mariadb redis revproxy
.PONY =
define gentarget
$(foreach name,$(CONTAINERS),$(1)@$(name))
endef
TARGET_LOGS = $(call gentarget,logs)
.PONY += $(TARGET_LOGS)
TARGET_LOGS_FOLLOW = $(call gentarget,logs-follow)
.PONY += $(TARGET_LOGS_FOLLOW)
TARGET_LOGS_TIME = $(call gentarget,logs-time)
.PONY += $(TARGET_LOGS_TIME)
TARGET_SHELL = $(call gentarget,shell)
.PONY += $(TARGET_SHELL)
define yesno
@read -p "$1 (y/N): " YN; \
case "$$YN" in [yY]*) true;; \
*) echo "Aborted ($${YN})"; false;; \
esac
endef
ps:
$(COMPOSE) ps
init:
./init.sh template.env
init-hpci:
./init.sh template-hpci.env
init-dev:
./init.sh template-docker_dev.env
prune:
$(DOCKER) system prune -f
selfsigned-cert-generate:
$(SSC_COMPOSE) up
$(SSC_COMPOSE) down
selfsigned-cert-ps:
$(SSC_COMPOSE) ps
selfsigned-cert-check-config:
$(SSC_COMPOSE) config
selfsigned-cert-fingerprint:
$(EXEC_COMMON_ROOT) revproxy /cert-fingerprint.sh
selfsigned-cert-logs:
$(SSC_COMPOSE) logs
check-config:
$(COMPOSE) config
down:
$(COMPOSE) down --remove-orphans
$(MAKE) prune
volume-list:
# @$(COMPOSE) config --volumes
@$(DOCKER) volume ls -q | grep $(COMPOSE_PROJECT_NAME)_
volume-list-2:
@ $(COMPOSE) ps -q \
| xargs docker container inspect \
-f '{{ range .Mounts }}{{ .Name }} {{ end }}' \
| xargs -n 1 echo
service-list:
@$(COMPOSE) config --services
_REMOVE_ALL_FOR_DEVELOP:
$(MAKE) down-REMOVE_VOLUMES || true
BACKUP_CONF=config.env.`date +%Y%m%d`; [ -f $$BACKUP_CONF ] || cp config.env || true
rm -f ./secrets/db_password
rm -f ./docker-compose.override.yml ./config.env
_REINSTAL_FOR_DEVELOP:
$(MAKE) _REMOVE_ALL_FOR_DEVELOP
$(MAKE) init-dev
$(MAKE) selfsigned-cert-generate
$(MAKE) reborn-withlog
down-REMOVE_VOLUMES_FORCE:
$(COMPOSE) down --volumes --remove-orphans
down-REMOVE_VOLUMES:
$(call yesno,ERASE ALL LOCAL DATA. Do you have a backup?)
$(MAKE) down-REMOVE_VOLUMES_FORCE
COMMIT_HASH := nextcloud/commit_hash.sh
commit_hash:
echo -n "NEXTCLOUD_GFARM_COMMIT_HASH=" > $(COMMIT_HASH)
git rev-parse HEAD >> $(COMMIT_HASH) || true
reborn-nowait:
$(MAKE) build
$(MAKE) down
$(COMPOSE) up -d || { $(MAKE) logs; false; }
$(MAKE) auth-init || { $(MAKE) logs; false; }
reborn:
$(MAKE) reborn-nowait
./wait.sh
reborn-withlog:
$(MAKE) reborn-nowait
$(MAKE) logs-follow
build: commit_hash
$(COMPOSE) build
build-nocache: commit_hash
$(COMPOSE) build --no-cache
stop:
$(COMPOSE) stop
restart-nowait:
$(COMPOSE) restart || $(MAKE) logs
$(MAKE) auth-init
restart:
$(MAKE) restart-nowait
./wait.sh
restart-withlog:
$(MAKE) restart-nowait
$(MAKE) logs-follow
restart@revproxy:
$(COMPOSE) restart revproxy
shell:
$(EXEC) /bin/bash
shell-root:
$(EXEC_ROOT) bash
$(TARGET_SHELL): shell@%:
$(COMPOSE) exec $* /bin/sh
logs:
$(MAKE) logs@nextcloud
logs-follow:
$(MAKE) logs-follow@nextcloud
logs-all-follow:
$(COMPOSE) logs --tail 10 --follow
nextcloud.log:
$(OCC) log:tail 10000 | sed 's/\s*$$//g'
nextcloud.log-follow:
$(OCC) log:tail -f | sed 's/\s*$$//g'
$(TARGET_LOGS): logs@%:
$(COMPOSE) logs $*
$(TARGET_LOGS_FOLLOW): logs-follow@%:
$(COMPOSE) logs --tail 10000 --follow $*
$(TARGET_LOGS_TIME): logs-time@%:
$(COMPOSE) logs --timestamps $*
ECHO_PROJECT_NAME:
@echo $(COMPOSE_PROJECT_NAME)
ECHO_SUDO:
@echo $(SUDO)
ECHO_DOCKER:
@echo eval $(DOCKER)
ECHO_COMPOSE:
@echo eval $(COMPOSE)
occ-add-missing-indices:
$(OCC) db:add-missing-indices
occ-maintenancemode-on:
@$(OCC) maintenance:mode --on
occ-maintenancemode-off:
@$(OCC) maintenance:mode --off
files-scan:
$(EXEC) /nc-gfarm/files_scan.sh
backup-force:
$(EXEC) /nc-gfarm/backup.sh
backup:
$(call yesno,Nextcloud service will be temporarily stopped. Do you wish to continue?)
$(MAKE) backup-force
restore-test:
$(EXEC_ROOT) /nc-gfarm/restore-test.sh
auth-init:
$(MAKE) grid-proxy-init
$(MAKE) myproxy-logon
grid-proxy-init-withlog:
$(MAKE) grid-proxy-init
$(MAKE) logs-follow
grid-proxy-init:
$(EXEC) /nc-gfarm/grid-proxy-init.sh
grid-proxy-init-force:
$(EXEC) /nc-gfarm/grid-proxy-init.sh --force
myproxy-logon-withlog:
$(MAKE) myproxy-logon
$(MAKE) logs-follow
myproxy-logon:
$(EXEC) /nc-gfarm/myproxy-logon.sh
myproxy-logon-force:
$(EXEC) /nc-gfarm/myproxy-logon.sh --force
grid-proxy-info:
$(EXEC) grid-proxy-info
gfkey-e:
$(EXEC) gfkey -e
timeleft-proxy_cert:
$(EXEC) /nc-gfarm/timeleft-proxy_cert.sh
timeleft-gfarm_shared_key:
$(EXEC) /nc-gfarm/timeleft-gfarm_shared_key.sh
gfarm_check_online:
$(EXEC) bash /nc-gfarm/gfarm_check_online.sh
gfarm_check_online-verbose:
$(EXEC) bash -x /nc-gfarm/gfarm_check_online.sh
copy-gfarm_shared_key:
$(EXEC_ROOT) /nc-gfarm/copy_gfarm_shared_key.sh
copy-gsi_user_proxy:
$(EXEC_ROOT) /nc-gfarm/copy_gsi_user_proxy.sh
resetpassword-admin:
./resetpassword-admin.sh "$(EXEC_COMMON_USER)" nextcloud
show-nextcloud-version:
$(OCC) --version
cron-force:
$(EXEC) php /var/www/html/cron.php
version:
@$(EXEC) cat /nc-gfarm/version.txt