Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Copy the files in a local folder accessible from each node. 
The idea is that we run node_clone from a node where we can use clush and then we run node_copy on the nodes that need to be copied.

How to run

On a machine with clush, run: 

node_clone.sh drp_srcf_cmp001 drp_srcf_cmp002

It requires as parameters the from and to node address:

node_copy.sh:

This script copies the files in the file_list.json file from and to the local folder. 
It is run "remotely" directly on the selected nodes.
The script proceeds in creating local folders in the same directory the script is run (BACKUP_TEMP and DEFAULTS_TEMP).

...

  • chmod -x /usr/lib/systemd/system/tdetsim.service
  • chmod -x /usr/lib/systemd/system/kcu.service
  • systemctl disable irqbalance.service
  • systemctl daemon-reload
  • systemctl start tdetsim.service
Code Block
#!/bin/bash 
reverse=0 
while getopts ":r" option; do
   case $option in
      r) # display Help
         reverse=1
        ;;
   esac
done
datedir="$(date +'%Y-%m-%d')"
PATH_SCRIPTS=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
reverse=0
HOST=$(hostname)
input="$PATH_SCRIPTS/file_list.json"
count=$(jq '.driver | length' "$input")

if [ ! -d "$PATH_SCRIPTS/BACKUP_TEMP/" ]; then
  mkdir "$PATH_SCRIPTS/BACKUP_TEMP/"
fi 
datedir="$(date +'%Y-%m-%d')"
if [ ! -d "$PATH_SCRIPTS/BACKUP_TEMP/$datedir" ]; then
  mkdir "$PATH_SCRIPTS/BACKUP_TEMP/$datedir"
fi 
if [ ! -d "$PATH_SCRIPTS/DEFAULTS_TEMP/" ]; then
  mkdir "$PATH_SCRIPTS/DEFAULTS_TEMP/"  
fi     
if [ ! -d "$PATH_SCRIPTS/BACKUP_TEMP/$datedir/$HOST" ]; then
	mkdir "$PATH_SCRIPTS/BACKUP_TEMP/$datedir/$HOST"
fi 
NODE_LABEL1=$(cat /proc/datadev_0 | grep 'Build String' | cut -d ' ' -f 13)
NODE_LABEL=${NODE_LABEL1::-1} 
count=$(jq '.driver | length' "$input") 
if([ $reverse == 0 ]); then
	
	for ((i=0; i<$count; i++)); do

		VARIABLE=$(jq -r .driver["$i"].driver_name "$input")
		BACKUP_FOLDER=$(jq -r .driver["$i"].install_path "$input")
		ACTIVE=$(jq -r .driver["$i"].active "$input")

		echo "$BACKUP_FOLDER/$VARIABLE" "$PATH_SCRIPTS/DEFAULTS_TEMP/"
		cp "$BACKUP_FOLDER/$VARIABLE" "$PATH_SCRIPTS/DEFAULTS_TEMP/"

	done < "$input"
else
	if [ -d "$PATH_SCRIPTS/DEFAULTS_TEMP/" ]; then
		for ((i=0; i<$count; i++)); do

			VARIABLE=$(jq -r .driver["$i"].driver_name "$input")
			BACKUP_FOLDER=$(jq -r .driver["$i"].install_path "$input")
			ACTIVE=$(jq -r .driver["$i"].active "$input")
			echo "$BACKUP_FOLDER$VARIABLE" "$PATH_SCRIPTS/BACKUP_TEMP/$datedir/$HOST/"
			cp "$BACKUP_FOLDER/$VARIABLE" "$PATH_SCRIPTS/BACKUP_TEMP/$datedir/$HOST/"
			echo "$PATH_SCRIPTS/DEFAULTS_TEMP/$VARIABLE" "$BACKUP_FOLDER"
			cp "$PATH_SCRIPTS/DEFAULTS_TEMP/$VARIABLE" "$BACKUP_FOLDER"
		done < "$input"

	    	chmod -x /usr/lib/systemd/system/tdetsim.service
	    	chmod -x /usr/lib/systemd/system/kcu.service
	    	systemctl disable irqbalance.service
		systemctl daemon-reload
		if [ $NODE_LABEL == 'DrpTDet' ];then
			systemctl start tdetsim.service
    else
      systemctl start kcu.service
    fi  
	else
		echo "There is no DEFAULTS_TEMP folder"	
	fi
fi

...

This script must be run in a node with clush installed, like drp-neh-ctl002. Since the FEE and SRCF are reachable by ssh, it is possible to run this script from neh to srcf systems and viceversa.
It requires as parameters the from and to node address:node_clone drp_srcf_cmp001 drp_srcf_cmp002.

The script stops if these addresses are not provided.

...