blob: 779e07f70fbf3b40d970e8d2015ccf8fb0842627 (
plain)
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
|
#!/usr/bin/env sh
#
# ziti-edge-tunnel-enroll.sh
#
# enroll all identity tokens found in ZITI_IDENTITY_DIR
set -eu
for JWT in ${ZITI_IDENTITY_DIR}/*.jwt; do
# handle case where JWT='/opt/openziti/etc/identities/*.jwt'
[ -e "${JWT}" ] || {
echo "NOTICE: no new JWT files in ${JWT}" >&2
continue
}
[ -r "${JWT}" ] || {
echo "WARN: skipping unreadable JWT file in ${JWT}" >&2
continue
}
[ -s "${JWT}" ] || {
echo "WARN: skipping empty JWT file in ${JWT}" >&2
continue
}
# equivalent to BASH's ${JWT%.jwt}.json
CONFIG="$(echo "${JWT}" | sed -E 's|(.*).jwt|\1.json|')"
if ziti-edge-tunnel enroll --jwt ${JWT} --identity ${CONFIG}; then
rm --force "${JWT}"
echo "INFO: enrolled $(basename "${JWT}") in ${CONFIG}"
else
echo "ERROR: failed to enroll $(basename "${JWT}") in $(dirname "${JWT}")" >&2
exit 1
fi
done
|