Full document, spreadsheet, slideshow, and diagram tooling
1#!/bin/sh
2set -e
3
4# Generate /srv/instance-info.json from environment variables.
5# If INSTANCE_FLAVOR is not set, the baked-in file from the build is used as-is.
6
7if [ -n "$INSTANCE_FLAVOR" ]; then
8 SYNC=false; SHARING=false; AI=false
9 case ",$INSTANCE_FEATURES," in *,sync,*) SYNC=true;; esac
10 case ",$INSTANCE_FEATURES," in *,sharing,*) SHARING=true;; esac
11 case ",$INSTANCE_FEATURES," in *,ai,*) AI=true;; esac
12
13 OP=null
14 [ -n "$INSTANCE_OPERATOR" ] && OP="\"$INSTANCE_OPERATOR\""
15
16 PDS=null
17 [ -n "$INSTANCE_PDS" ] && PDS="\"$INSTANCE_PDS\""
18
19 NOTICE=null
20 [ -n "$INSTANCE_NOTICE" ] && NOTICE="\"$INSTANCE_NOTICE\""
21
22 AC=null
23 if [ "$INSTANCE_ACCESS_MODE" = "allowlist" ] && [ -n "$INSTANCE_ALLOWLIST" ]; then
24 DIDS=$(printf '%s' "$INSTANCE_ALLOWLIST" | sed 's/,/","/g')
25 AC="{\"mode\":\"allowlist\",\"allowlist\":[\"$DIDS\"]}"
26 elif [ "$INSTANCE_ACCESS_MODE" = "open" ]; then
27 AC="{\"mode\":\"open\"}"
28 fi
29
30 cat > /srv/instance-info.json <<EOF
31{
32 "flavor": "$INSTANCE_FLAVOR",
33 "operator": $OP,
34 "pds": $PDS,
35 "features": {
36 "sync": $SYNC,
37 "sharing": $SHARING,
38 "ai": $AI
39 },
40 "notice": $NOTICE,
41 "accessControl": $AC
42}
43EOF
44fi
45
46exec "$@"