-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure_ms.mk
50 lines (36 loc) · 1.58 KB
/
configure_ms.mk
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
# MS configuration parameters
# Where app.yamlin can be found
CONFIG_DIR ?= .
# Output directory for app.yaml
BUILD_MS ?=
# Where to put generated pub/priv keys
KEY_FILES ?= $(CONFIG_DIR)
MS_APP_NAME ?= syndicate-ms
MS_APP_PUBLIC_HOST ?= localhost
MS_APP_ADMIN_EMAIL ?= [email protected]
MS_APP_ADMIN_PUBLIC_KEY ?= $(KEY_FILES)/admin.pub
MS_APP_ADMIN_PRIVATE_KEY ?= $(KEY_FILES)/admin.pem
MS_APP_PUBLIC_KEY ?= $(KEY_FILES)/syndicate.pub
MS_APP_PRIVATE_KEY ?= $(KEY_FILES)/syndicate.pem
$(MS_APP_ADMIN_PRIVATE_KEY):
openssl genrsa 4096 > "$@"
$(MS_APP_ADMIN_PUBLIC_KEY): $(MS_APP_ADMIN_PRIVATE_KEY)
openssl rsa -in "$<" -pubout > "$@"
$(MS_APP_PRIVATE_KEY):
openssl genrsa 4096 > "$@"
$(MS_APP_PUBLIC_KEY): $(MS_APP_PRIVATE_KEY)
openssl rsa -in "$<" -pubout > "$@"
$(BUILD_MS)/app.yaml: $(CONFIG_DIR)/app.yamlin $(MS_APP_ADMIN_PUBLIC_KEY) $(MS_APP_PUBLIC_KEY) $(MS_APP_PRIVATE_KEY)
mkdir -p "$(@D)"
cat "$<" | \
sed -e 's~@MS_APP_NAME@~$(MS_APP_NAME)~g;' \
-e 's~@MS_APP_PUBLIC_HOST@~$(MS_APP_PUBLIC_HOST)~g;' \
-e 's~@MS_APP_ADMIN_EMAIL@~$(MS_APP_ADMIN_EMAIL)~g;' \
-e 's~@MS_APP_ADMIN_PUBLIC_KEY@~$(shell cat "$(MS_APP_ADMIN_PUBLIC_KEY)" | tr "\n" "@ " | sed 's/@/\\n /g')~g;' \
-e 's~@MS_APP_PUBLIC_KEY@~$(shell cat "$(MS_APP_PUBLIC_KEY)" | tr "\n" "@" | sed 's/@/\\n /g')~g;' \
-e 's~@MS_APP_PRIVATE_KEY@~$(shell cat "$(MS_APP_PRIVATE_KEY)" | tr "\n" "@" | sed 's/@/\\n /g')~g;' \
> "$@"
clean_ms:
rm -f $(BUILD_MS)/ms/app.yaml
clean_certs: clean_ms
rm -f $(MS_APP_ADMIN_PUBLIC_KEY) $(MS_APP_ADMIN_PRIVATE_KEY) $(MS_APP_PUBLIC_KEY) $(MS_APP_PRIVATE_KEY)