瀏覽代碼

fix: prevent /etc/hosts domain duplication

Ivan Augusto 3 年之前
父節點
當前提交
2b4dd30bbc
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      compose/bin/setup-domain

+ 4 - 2
compose/bin/setup-domain

@@ -5,8 +5,10 @@ set -o errexit
 
 DOMAIN=$1
 
-echo "Your system password has been requested to add an entry to /etc/hosts..."
-echo "127.0.0.1 ::1 $DOMAIN" | sudo tee -a /etc/hosts
+if ! grep -q $DOMAIN /etc/hosts; then
+    echo "Your system password is needed to add an entry to /etc/hosts..."
+    echo "127.0.0.1 ::1 $DOMAIN" | sudo tee -a /etc/hosts
+fi
 
 echo "Set https://${DOMAIN}/ to web/secure/base_url and web/secure/base_url"
 bin/clinotty bin/magento config:set web/secure/base_url https://"$DOMAIN"/