Two small changes to start script.

1. Grep can be used to read from a file directly instead of piping from cat.
2. Quotes on 146 ${ENV_FILE} will cause it to only loop once, according to JetBrains and https://github.com/koalaman/shellcheck/wiki/SC2066.
This commit is contained in:
Justin Trujillo 2022-05-28 01:44:43 -06:00
parent 2faa38dd43
commit 15ab889875

View file

@ -115,7 +115,7 @@ fi
# Get current dns from host
if [[ -f "/etc/resolv.conf" ]]; then
TEMP=$(cat /etc/resolv.conf | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -n 1)
TEMP=$(grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' /etc/resolv.conf | head -n 1)
fi
# Get dns ip if pihole is installed
@ -143,7 +143,7 @@ ENV_FILE=$(mktemp)
JWT_SECRET=$(derive_entropy "jwt")
for template in "${ENV_FILE}"; do
for template in ${ENV_FILE}; do
sed -i "s/<dns_ip>/${DNS_IP}/g" "${template}"
sed -i "s/<internal_ip>/${INTERNAL_IP}/g" "${template}"
sed -i "s/<tz>/${TZ}/g" "${template}"