Browse Source

HPCC-16099 Add check to init-functions for getopt compatibility

Signed-off-by: Michael Gardner <michael.gardner@lexisnexis.com>
Michael Gardner 8 năm trước cách đây
mục cha
commit
f1ccb429a6

+ 2 - 0
initfiles/bash/etc/init.d/dafilesrv.in

@@ -88,6 +88,8 @@ if [ $? -ne 1 ];then
    exit 3
 fi
 
+check_getopt
+
 COMPS=$(${configgen_path}/configgen -env ${envfile} -ip "127.0.0.1" -list)
 if [[ $rc -ne 0 ]]; then
     log "hpcc-init: failure to build COMPS from configgen call"

+ 3 - 1
initfiles/bash/etc/init.d/hpcc-init.in

@@ -135,7 +135,9 @@ if [ $? -ne 1 ];then
    log  "Group for user ${group} does not exist on the system. Exiting ..."
    echo "Group for user ${group} does not exist on the system. Exiting ..."
    exit 3
-fi 
+fi
+
+check_getopt
 
 #changing ownership of the home directory for user.
 chown -cR $user:$group ${home}/${user} 1>/dev/null 2>/dev/null

+ 17 - 0
initfiles/bash/etc/init.d/init-functions

@@ -376,6 +376,23 @@ log_action_end_msg () {
     log_action_end_msg_post "$@"
 }
 
+check_getopt () {
+  `getopt -T 1>/dev/null 2>&1`
+  if [ $? -ne 4 ]; then
+    echo "Incompatible version of getopt"
+    os=$(uname)
+    if [ "${os}" == "Darwin" ]; then
+      echo "Update from an external source"
+      echo "Example: brew install gnu-getopt"
+    elif [ "${os}" == "Linux" ]; then
+      echo "insure the environment variable GETOPT_COMPATIBLE is unset"
+    else
+      echo "getopt must support long options"
+    fi
+    exit 3
+  fi
+}
+
 distrib_check () {
   DISTRIB_NAME=
   DISTRIB_VERSION=