Check if PLC_(WWW|API|BOOT)_IP can be obtained via gethostbyname and
authorMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 29 Aug 2008 15:02:45 +0000 (15:02 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 29 Aug 2008 15:02:45 +0000 (15:02 +0000)
cause script to fail if not.  Otherwise we have silent failures, which
to the new user are annoying to figure out.

plc.d/postgresql

index 43fc7aa..8105637 100755 (executable)
@@ -101,6 +101,27 @@ case "$1" in
        PLC_API_IP=$(gethostbyname $PLC_API_HOST)
        PLC_BOOT_IP=$(gethostbyname $PLC_BOOT_HOST)
        PLC_WWW_IP=$(gethostbyname $PLC_WWW_HOST)
+       ip_failure=0
+       if [ -z "$PLC_API_IP" ] ; then
+           MESSAGE=$"PLC_API_IP is not set"
+           dialog "$MESSAGE"
+           ip_failure=1
+       fi
+       if [ -z "$PLC_BOOT_IP" ] ; then
+           MESSAGE=$"PLC_BOOT_IP is not set"
+           dialog "$MESSAGE"
+           ip_failure=1
+       fi
+       if [ -z "$PLC_WWW_IP" ] ; then
+           MESSAGE=$"PLC_WWW_IP is not set"
+           dialog "$MESSAGE"
+           ip_failure=1
+       fi
+       if [ $ip_failure -eq 1 ] ; then
+           /bin/false
+           check
+       fi
+
        (
            echo "host $PLC_DB_NAME $PLC_DB_USER 127.0.0.1/32 password"
            echo "host $PLC_DB_NAME $PLC_DB_USER $PLC_API_IP/32 password"