瀏覽代碼

Fixed: #81549 - New push/run scripts added.

This is a rollup of all commits for the branch script_updates.

Removing old script files.

Added new scritps for pushing files and running commands.

Setting perms on /etc/HPCCSystems to be owned by hpcc.

Adding in script files to install.

Updating install to make sure perms are right and fixing copyright utf8 logo.

Fixed: #81549 - Fixed issue presented by link dereferencing if /etc/HPCCSystems is a symlink.

Fixed: #81549 - Changing if syntax that has issues on shell and older versions
of bash.

Updated hpcc-run.sh.in to have Richards fix for Bug: #82053.

Fixed: 82093 - Removed force of changing permissions as it is not needed and breaks sub dirs in the directory.

Removed invalid lines from the buildCmd function

Signed-off-by: Philip Schwartz <philip.schwartz@lexisnexis.com>
Philip Schwartz 14 年之前
父節點
當前提交
2d978c7dba

+ 2 - 1
initfiles/bash/etc/init.d/install-init.in

@@ -232,4 +232,5 @@ if [ -d ${confPath} ]; then
     done
 fi
 
-
+chown root:$group ${configs}
+chown -R $user:$group ${configs}/*

+ 2 - 0
initfiles/sbin/CMakeLists.txt

@@ -6,5 +6,7 @@ GENERATE_BASH(processor ${bash-vars} "hpcc_setenv.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "keygen.sh.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "prerm.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "rm_conf_settings.sh.in" outFiles)
+GENERATE_BASH(processor ${bash-vars} "hpcc-push.sh.in" outFiles)
+GENERATE_BASH(processor ${bash-vars} "hpcc-run.sh.in" outFiles)
 ADD_CUSTOM_TARGET(ProcessFiles-initfiles-sbin ALL DEPENDS ${outFiles})
 

+ 58 - 0
initfiles/sbin/hpcc-push.sh.in

@@ -0,0 +1,58 @@
+#!/bin/bash
+##
+## Copyright (c) 2011 HPCC Systems.  All rights reserved.
+##
+## version v0.1
+## author Philip Schwartz <philip.schwartz@lexisnexis.com>
+##
+## Usage: hpcc-push.sh <from> <to>
+##
+## This is acomplished with a standard scp command with the use of the 
+## runtime users id_rsa file.
+
+###<REPLACE>###
+
+
+source  ${INSTALL_DIR}/etc/init.d/lock.sh
+source  ${INSTALL_DIR}/etc/init.d/pid.sh
+source  ${INSTALL_DIR}/etc/init.d/hpcc_common
+source  ${INSTALL_DIR}/etc/init.d/init-functions
+source  ${INSTALL_DIR}/etc/init.d/export-path
+
+
+getIPS(){
+	IPS=`${INSTALL_DIR}/sbin/configgen -env ${envfile} -machines | awk -F, '{print \$1}'  | sort | uniq`
+}
+
+copyFile(){
+	echo "$IP: Copying $1 to $2 on $IP";
+	SCP=`scp -i $home/$user/.ssh/id_rsa $1 $user@$IP:$2; echo $?`
+	if [ "$SCP" -eq 0 ]; then
+		echo "$IP: Success";
+	else
+		echo "$IP: Failure";
+	fi
+}
+
+if [ $# -ne 2 ]; then
+	echo "usage: hpcc-push.sh [user@]host1:]file1 [[user@]host2:]file2"
+fi
+
+set_envrionmentvars
+envfile=$configs/$environment
+
+getIPS
+
+for IP in $IPS; do
+	if ping -c 1 -w 5 -n $IP > /dev/null 2>&1; then
+		echo "$IP: Host is alive."
+		CAN_SSH="`ssh -i $home/$user/.ssh/id_rsa -o BatchMode=yes -o StrictHostKeyChecking=no $user@$IP exit > /dev/null 2>&1; echo $?`"
+		if [ "$CAN_SSH" -eq 255 ]; then
+			echo "$IP: Cannot SSH to host.";
+		else
+			copyFile $1 $2
+		fi
+	else
+		echo "$IP: FAIL"
+	fi
+done

+ 100 - 0
initfiles/sbin/hpcc-run.sh.in

@@ -0,0 +1,100 @@
+#!/bin/bash
+##
+## Copyright (c) 2011 HPCC Systems.  All rights reserved.
+##
+## version v0.1
+## author Philip Schwartz <philip.schwartz@lexisnexis.com>
+##
+## Usage: hpcc-run.sh [hpcc-init | dafilesrv] [-c component] <cmd>
+##
+## This is acomplished with a standard ssh command with the use of the 
+## runtime users id_rsa file.
+
+###<REPLACE>###
+
+source  ${INSTALL_DIR}/etc/init.d/lock.sh
+source  ${INSTALL_DIR}/etc/init.d/pid.sh
+source  ${INSTALL_DIR}/etc/init.d/hpcc_common
+source  ${INSTALL_DIR}/etc/init.d/init-functions
+source  ${INSTALL_DIR}/etc/init.d/export-path
+
+print_usage(){
+	echo "usage: hpcc-run.sh [-c component] [-a {hpcc-init|dafilesrv}] {start|stop|restart|status|setup}"
+	exit 1
+}
+
+getIPS(){
+	IPS=`${INSTALL_DIR}/sbin/configgen -env ${envfile} -machines | awk -F, '{print \$1}'  | sort | uniq`
+}
+
+buildCmd(){
+	if [ -z $3 ]; then
+		CMD="sudo /etc/init.d/$1 $2"
+	else
+		CMD="sudo /etc/init.d/$1 -c $3 $2"
+	fi
+}
+
+runCmd(){
+	echo "$IP: Running $@";
+	ssh -i $home/$user/.ssh/id_rsa $user@$IP $@;
+}
+
+set_envrionmentvars
+envfile=$configs/$environment
+
+getIPS
+
+TEMP=`/usr/bin/getopt -o a:c:h --long help,action -n 'hpcc-run' -- "$@"`
+if [ $? != 0 ] ; then echo "Failure to parse commandline." >&2 ; exit 1 ; fi
+eval set -- "$TEMP"
+while true ; do
+    case "$1" in
+        -c) comp=$2
+            shift 2 ;;
+	-a|--action) action=$2
+	    shift 2 ;;
+        -h|--help) print_usage
+                   shift ;;
+        --) shift ; break ;;
+        *) print_usage ;;
+    esac
+done
+for arg do arg=$arg; done
+
+case "$action" in
+    hpcc-init) ;;
+    dafilesrv) ;;
+    *) if [ -z $action ]; then
+	    action="hpcc-init"
+	else
+	    print_usage 
+        fi
+	;;
+esac
+
+case "$arg" in
+    start) cmd="start" ;;
+    stop) cmd="stop" ;;
+    restart) cmd="restart" ;;
+    status) cmd="status" ;;
+    setup) cmd="setup" ;;
+    *) print_usage;;
+esac
+
+
+
+for IP in $IPS; do
+	if ping -c 1 -w 5 -n $IP > /dev/null 2>&1; then
+		echo "$IP: Host is alive."
+		CAN_SSH="`ssh -i $home/$user/.ssh/id_rsa -o BatchMode=yes -o StrictHostKeyChecking=no $user@$IP exit > /dev/null 2>&1; echo $?`"
+		if [ "$CAN_SSH" -eq 255 ]; then
+			echo "$IP: Cannot SSH to host.";
+		else
+			buildCmd $action $cmd $comp
+			runCmd $CMD
+		fi
+	else
+		echo "$IP: FAIL"
+	fi
+done

+ 0 - 44
initfiles/sbin/push.sh

@@ -1,44 +0,0 @@
-#!/bin/bash
-################################################################################
-## Copyright © 2011 HPCC Systems.  All rights reserved.
-################################################################################
-
-#################################################################################
-# Description:
-#        This is a script to push a file from one machine over to the cluster
-#        of machines. 
-#
-#################################################################################
-
-username=$1
-password=$2
-file=$3
-to=$4
- 
-EXPECTEDARGS=4
-
-if [ $# -ne $EXPECTEDARGS ]; then
-    echo "USAGE:./push.sh <username> <password> <filename to be pushed> <file destination location> "
-    exit
-fi
- 
-instance_1_server=10.239.219.1
-instance_2_server=10.239.219.2
-instance_3_server=10.239.219.3
-instance_4_server=10.239.219.4
- 
-servers=("$instance_1_server" "$instance_2_server" "$instance_3_server" "$instance_4_server")
-i=1
-for server in ${servers[@]}; do
-    expect -c "
-              set timeout -1
-              # exp_internal 1 # uncomment for debugging
-              spawn /usr/bin/scp $file $username@$server:$to
-              expect { 
-                "*?assword:*" { send $password\r\n; interact } 
-                eof { exit }
-              }
-              exit
-              "
-    let "i=i+1"
-done

+ 0 - 43
initfiles/sbin/run.sh

@@ -1,43 +0,0 @@
-#!/bin/bash
-################################################################################
-## Copyright © 2011 HPCC Systems.  All rights reserved.
-################################################################################
-
-#################################################################################
-# Description:
-#        This is a script to run a command from one machine over to the cluster
-#        of machines. 
-#
-#################################################################################
-
-username=$1
-password=$2
-cmd=$3
-
-EXPECTEDARGS=3
-
-if [ $# -ne $EXPECTEDARGS ]; then
-    echo "USAGE:./run.sh <username> <password> <command to run> "
-    exit
-fi
- 
-instance_1_server=10.239.219.1
-instance_2_server=10.239.219.2
-instance_3_server=10.239.219.3
-instance_4_server=10.239.219.4
- 
-servers=("$instance_1_server" "$instance_2_server" "$instance_3_server" "$instance_4_server")
-i=1
-for server in ${servers[@]}; do
-    expect -c "
-              set timeout -1
-              exp_internal 1 # uncomment for debugging
-              spawn /usr/bin/ssh $username@$server $cmd
-              expect { 
-                "*?assword:*" { send $password\r\n; interact } 
-            eof { exit }
-              }
-              exit
-              "
-    let "i=i+1"
-done

+ 0 - 36
initfiles/sbin/run_cmd.sh

@@ -1,36 +0,0 @@
-#!/bin/bash
-################################################################################
-## Copyright © 2011 HPCC Systems.  All rights reserved.
-################################################################################
-
-#################################################################################
-# Description:
-#        This is a script to run a command from one machine. 
-#
-#################################################################################
-
-server=$1
-username=$2
-password=$3
-cmd=$4
-
-EXPECTEDARGS=4
-
-if [ $# -ne $EXPECTEDARGS ]; then
-    echo "USAGE:./run_cmd.sh <server> <username> <password> <command to run> "
-    exit
-fi
- 
-expect -c "
-          set timeout -1
-          # exp_internal 1 # uncomment for debugging
-          spawn /usr/bin/ssh $username@$server $cmd
-          expect { 
-            "*?assword:*" { send $password\r\n; interact } 
-            eof { exit }
-          }
-          exit
-          "
-
-exit
-

+ 4 - 0
install_directory/bash_startup.install

@@ -138,5 +138,9 @@ install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/initfiles/bin/init_sasha DESTINATION
 install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/initfiles/bin/init_thor DESTINATION ${OSSDIR}/bin
     PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
 
+install ( FILES ${CMAKE_BINARY_DIR}/initfiles/sbin/hpcc-push.sh DESTINATION ${OSSDIR}/sbin
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
 
+install ( FILES ${CMAKE_BINARY_DIR}/initfiles/sbin/hpcc-run.sh DESTINATION ${OSSDIR}/sbin
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )