install-osrf.sh: avoid appending useless entries to /etc/hosts
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Wed, 18 May 2016 19:23:43 +0000 (12:23 -0700)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Wed, 18 May 2016 19:23:43 +0000 (12:23 -0700)
deployment/install-osrf.sh

index 5f26444..8ec185f 100755 (executable)
@@ -78,9 +78,15 @@ chown -R opensrf:opensrf ${INSTALLDIR}
 # as root, add the following two lines to /etc/hosts:
 #127.0.1.2     public.localhost        public
 #127.0.1.3     private.localhost       private
-echo "Updating /etc/hosts..."
-echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
-  cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
+if [[ ! -n "$PROD" ]] ; then
+  if [[ ! `grep public.localhost /etc/hosts` ]] ; then
+    echo "Updating /etc/hosts..."
+    echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
+      cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
+  fi
+else
+  echo 'WARNING: If this is a new production server, you will need to manually update /etc/hosts!'
+fi
  
 # as root
 echo "ldconfig stuff..."