瀏覽代碼

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.

Justin Trujillo 3 年之前
父節點
當前提交
15ab889875
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      scripts/start.sh

+ 2 - 2
scripts/start.sh

@@ -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}"