. rdqmCommon.sh

basehostname=$(cat /etc/hostname | sed 's/[[:digit:]]\.fyre\.ibm\.com//')
echoBig "Base Hostname is: $basehostname"

initRDQMSetup

echoBig "User: $user | node1: $node1 | node2: $node2 | node3: $node3 | sshCommand: $sshCommand"

CREATE SSH KEYS          #
############################
echoBig "Creating SSH keys"
generateSSHKey $node1

if [ $? != 0 ]
then
  echoBig "Failed generating SSH Key for $node1"
  exit 1
fi

generateSSHKey $node2

if [ $? != 0 ]
then
  echoBig "Failed generating SSH Key for $node2"
  exit 1
fi

generateSSHKey $node3

if [ $? != 0 ]
then
  echoBig "Failed generating SSH Key for $node2"
  exit 1
fi

############################
# SSH N1 -> N2 & N3        #
############################
echoBig "SSH N1 -> N2 & N3"
addPasswordlessSSH $node1 $node2

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node1 to $node2"
  exit 1
fi

addPasswordlessSSH $node1 $node3

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node1 to $node3"
  exit 1
fi

############################
# SSH N2 -> N1 & N3        #
############################
echoBig "SSH N2 -> N1 & N3"
addPasswordlessSSH $node2 $node1

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node2 to $node1"
  exit 1
fi

addPasswordlessSSH $node2 $node3

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node2 to $node3"
  exit 1
fi

############################
# SSH N3 -> N1 & N2        #
############################
echoBig "SSH N3 -> N1 & N2"
addPasswordlessSSH $node3 $node1

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node3 to $node1"
  exit 1
fi

addPasswordlessSSH $node3 $node2

if [ $? != 0 ]
then
  echoBig "Failed adding passwordless SSH from $node3 to $node2"
  exit 1
fi

##############################################################
# Allow passwordless SSH without StrictHostKeyChecking=no    #
##############################################################

#####################################################
# Add hostnames to the mqm user's known_hosts file! #
#####################################################
addRemoteKeyToKnownHosts $(echo "$node2" | cut -f1 -d\.) mqm

addRemoteKeyToKnownHosts $(echo "$node3" | cut -f1 -d\.) mqm

#####################################################################
# Add fully qualified hostnames to the mqm user's known_hosts file! #
#####################################################################
addRemoteKeyToKnownHosts "$node2" mqm

addRemoteKeyToKnownHosts "$node3" mqm

########################################################
# Add IP addresses to the mqm user's known_hosts file! #
########################################################
ip=$(grep $node2 /etc/hosts | cut -f1 -d\ )
addRemoteKeyToKnownHosts $ip mqm

ip=$(grep $node3 /etc/hosts | cut -f1 -d\ )
addRemoteKeyToKnownHosts $ip mqm

