-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
46 lines (35 loc) · 1.3 KB
/
entrypoint.sh
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
#!/bin/bash
if [[ -n "$ZITI_IDENTITY" ]]; then
echo "ZITI_IDENTITY detected, creating /app/identity.json..."
echo "$ZITI_IDENTITY" | base64 -d > /app/identity.json
if [[ $? -eq 0 ]]; then
echo "Identity file /app/identity.json created successfully."
export ZITI_IDENTITIES=/app/identity.json
echo "Exported ZITI_IDENTITIES=/app/identity.json"
else
echo "Error: Failed to decode and create identity file."
exit 1
fi
else
echo "ZITI_IDENTITY not detected. Checking ZITI_IDENTITIES for configuration..."
if [[ -z "$ZITI_IDENTITIES" ]]; then
echo "Error: ZITI_IDENTITIES is not set. Please configure it as a file pattern."
exit 1
fi
dir=$(dirname "$ZITI_IDENTITIES")
pattern=$(basename "$ZITI_IDENTITIES")
if [[ ! -d "$dir" ]]; then
echo "Error: Directory $dir does not exist."
exit 1
fi
echo "Scanning for files matching: $ZITI_IDENTITIES"
files=$(find "$dir" -maxdepth 1 -name "$pattern" -type f,l 2>/dev/null | tr '\n' ',' | sed 's/,$//')
if [[ -n "$files" ]]; then
export ZITI_IDENTITIES="$files"
echo "ZITI_IDENTITIES updated to: $ZITI_IDENTITIES"
else
echo "Error: No files found matching the pattern: $ZITI_IDENTITIES"
exit 1
fi
fi
exec "$@"