Versions Compared

Key

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

...

  • 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

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 

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
		systemctl start tdetsim.service
        
	else
		echo "There is no DEFAULTS_TEMP folder"	
	fi
fi


node_clone.sh:

is Is the "local" script that is used to run the cloning.

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 It requires as parameters the from and to node address: node_clone drp_srcf_cmp001 drp_srcf_cmp002the . The script stops if these addresses are not provided.

The user is then asked if the cloning procedure is correct. Y continues, N stops the procedure

The script proceeds in calling "clush" with root privileges running node_copy.sh in the from node. Then it runs again "clush" with root privileges on the to node but this time node_copy is called with -r option.

Code Block
#!/bin/bash
PATH_SCRIPTS=$(pwd)
HOST=$(hostname)
if [ $# -ne 2 ]; 
    then echo "Please provide from and to dns names"
    exit
fi

echo "This will clone $1 into $2"
read -r -p "Are you sure? [y/N] " 
if [[ $REPLY =~ ^[Yy]$ ]];
then 
	
	clush --mode sudo -w $1 "$PATH_SCRIPTS/node_copy.sh"
	clush --mode sudo -w $2 "$PATH_SCRIPTS/node_copy.sh -r"
        
fi
sudo rm -r "$PATH_SCRIPTS/DEFAULTS_TEMP/"


View file
namefile_list.json
height250
View file
namenode_copy.sh
height250
View file
namenode_clone.sh
height250

...