forked from EGA-archive/LocalEGA
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (102 loc) · 3.21 KB
/
Copy pathMakefile
File metadata and controls
135 lines (102 loc) · 3.21 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
SHELL := /bin/bash
DOCKER ?= podman
LEGA_UID := $(shell id -u lega)
LEGA_GID := $(shell id -g lega)
# LEGA_UID := $(shell id -u)
# LEGA_GID := $(shell id -g)
#############################
## Build docker images
#############################
define error-lega-gid-message
Please specify the group id via the LEGA_GID variable.
For example, by calling "make $@ LEGA_UID=$$(id -g lega)"
endef
image-inbox:
ifeq ($(LEGA_GID),)
$(error $(error-lega-gid-message))
endif
make -C ../../src/inbox latest LEGA_GID=$(LEGA_GID)
define error-lega-ugid-message
Please specify the user and group ids via the LEGA_UID/LEGA_GID variable.
For example, by calling "make $@ LEGA_UID=$$(id -u lega) LEGA_GID=$$(id -g lega)"
endef
image-handler:
ifeq ($(LEGA_UID),)
$(error $(error-lega-ugid-message))
endif
ifeq ($(LEGA_GID),)
$(error $(error-lega-ugid-message))
endif
make -C ../../src/handler latest LEGA_UID=$(LEGA_UID) LEGA_GID=$(LEGA_GID)
image-vault:
make -C ../../src/vault latest
images: image-inbox image-handler image-vault
#############################
## Initialize the database
#############################
init-vault:
ifeq ("$(wildcard pg_vault_su_password)","")
$(error 'Please specify the superuser password file "pg_vault_su_password"')
endif
make -C ../../src/vault init DB_DATA=$(shell pwd)/data/vault-db PG_SU_PASSWORD=$(file < pg_vault_su_password)
# Connect to the database from the host machine
export PGHOST=localhost
export PGPORT=5432
export PGUSER=postgres
export PGPASSWORD=$(file < pg_vault_su_password)
export PGDATABASE=ega
psql:
psql
# Apply the Inbox cleanup table to an existing Vault DB. New databases load
# it automatically from src/vault/initdb.d/35-inbox-cleanup.sql.
apply-inbox-cleanup-migration:
$(DOCKER) exec -i vault-db psql -v ON_ERROR_STOP=1 -U postgres -d ega < ../../src/vault/initdb.d/35-inbox-cleanup.sql
#############################
## Utility targets
#############################
down:
docker-compose down -v
logs:
docker-compose logs -f
ps:
docker-compose ps
clean:
-rm -rf data/{vault,staging,inbox}/*
-rm -rf data/vault-db
-rm -f data/example.txt.c4gh data/example.txt
#############################
## Distribution
#############################
# we need to sort to return the files in the desired order
SQL_FILES=$(sort $(notdir $(wildcard ../../src/distribution/src/db/*.sql)))
echo:
@echo $(SQL_FILES)
load: $(SQL_FILES:%=load-%)
export PGHOST=localhost
export PGPORT=5432
export PGUSER=postgres
export PGPASSWORD=$(file < pg_vault_su_password)
export PGDATABASE=ega
load-%:
psql < ../../src/distribution/src/db/$*
nss-users:
psql -c 'SELECT * FROM nss.make_users();'
nss-passwords:
psql -c 'SELECT * FROM nss.make_passwords();'
nss-groups:
psql -c 'SELECT * FROM nss.make_groups();'
nss-keys:
psql -c 'SELECT nss.make_authorized_keys(r.db_uid) FROM public.requesters r;'
nss: nss-users nss-passwords nss-groups nss-keys
#############################
## Upload example
#############################
data/example.txt.c4gh: data/example.txt
crypt4gh encrypt --recipient_pk service.key.pub < $< > $@
data/example.txt:
dd if=/dev/urandom bs=1024 count=2 > $@
example: data/example.txt.c4gh
sftp:
sftp -P 2222 john@localhost
permission:
curl http://localhost:8080/permission/jane/EGAD90000000123