-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcaddy-config-get
executable file
·51 lines (43 loc) · 1.15 KB
/
caddy-config-get
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
#!/bin/sh
set -e
set -u
if test -e ~/.config/caddy-sh/default.env; then
# shellcheck disable=SC1090
. ~/.config/caddy-sh/default.env
fi
if test -z "${CADDY_HOST:-}" ||
test -z "${CADDY_USER:-}" ||
test -z "${CADDY_PASS:-}"; then
echo ""
echo "Error: Set CADDY_HOST, CADDY_USER, and CADDY_PASS in '~/.config/caddy-sh/env'"
echo ""
exit 1
fi
fn_get_config() { (
curl -fsS --proto '=https' --tlsv1.2 \
-u "${CADDY_USER}:${CADDY_PASS}" \
"${CADDY_HOST}/config/" | jq
); }
main() { (
if test "help" = "${1:-}" ||
test "--help" = "${1:-}" ||
test -n "${1:-}"; then
echo ""
echo "USAGE"
echo " caddy-config-get"
echo ""
echo "EXAMPLES"
echo " caddy-config-get"
echo ""
echo "IMPORTANT:"
echo " BAD: caddy run --envfile ~/.config/caddy-sh/env --config ./caddy.json"
echo " GOOD: caddy run --envfile ~/.config/caddy-sh/env --resume"
echo ""
echo "Changes do NOT persist by default!"
echo ""
exit 1
fi
echo 'Getting Admin Config...'
fn_get_config
); }
main "${@:-}"