public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Trace
data/Dockerfiles/acme/load-dns-config.sh
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
#!/bin/bash
3
SCRIPT_SOURCE="${BASH_SOURCE[0]:-${0}}"
4
if [[ "${SCRIPT_SOURCE}" == "${0}" ]]; then
5
__dns_loader_standalone=1
6
else
7
__dns_loader_standalone=0
8
fi
10
CONFIG_PATH="${ACME_DNS_CONFIG_FILE:-/etc/acme/dns-01.conf}"
12
if [[ ! -f "${CONFIG_PATH}" ]]; then
13
if [[ $__dns_loader_standalone -eq 1 ]]; then
14
exit 0
15
else
16
return 0
17
fi
18
fi
20
source /srv/functions.sh
22
log_f "Loading DNS-01 configuration from ${CONFIG_PATH}"
24
LINE_NO=0
25
while IFS= read -r line || [[ -n "${line}" ]]; do
26
LINE_NO=$((LINE_NO+1))
27
line="${line%$'\r'}"
28
line_trimmed="$(printf '%s' "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
29
[[ -z "${line_trimmed}" ]] && continue
30
[[ "${line_trimmed:0:1}" == "#" ]] && continue
31
if [[ "${line_trimmed}" != *=* ]]; then
32
log_f "Skipping invalid DNS config line ${LINE_NO} (missing key=value)"
33
continue
34
fi
35
KEY="${line_trimmed%%=*}"
36
VALUE="${line_trimmed#*=}"
37
KEY="$(printf '%s' "${KEY}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
38
VALUE="$(printf '%s' "${VALUE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
39
if [[ -z "${KEY}" ]]; then
40
log_f "Skipping invalid DNS config line ${LINE_NO} (empty key)"
41
continue
42
fi
43
if [[ "${VALUE}" =~ ^\".*\"$ ]]; then
44
VALUE="${VALUE:1:-1}"
45
elif [[ "${VALUE}" =~ ^\'.*\'$ ]]; then
46
VALUE="${VALUE:1:-1}"
47
fi
48
export "${KEY}"="${VALUE}"
49
log_f "Exported DNS config key ${KEY}"
51
done < "${CONFIG_PATH}"
53
if [[ $__dns_loader_standalone -eq 1 ]]; then
54
exit 0
55
else
56
return 0
57
fi