2 # Connect to ODL Karaf shell. Mostly used for testing.
4 # Port that the Karaf shell listens on
7 # This could be done with public key crypto, but sshpass is easier
8 if ! command -v sshpass >/dev/null 2>&1 /dev/null; then
9 echo "Installing sshpass. It's used connecting non-interactively"
10 if ! sudo yum install -y sshpass; then
11 echo "Couldn't find sshpass pkg, trying to install EPEL"
12 if sudo yum install -y epel-release; then
13 echo "Installed EPEL, re-attempting to install sshpass"
14 sudo yum install -y sshpass
16 echo "Failed to install sshpass and EPEL, giving up"
22 echo "Will repeatedly attempt connecting to Karaf shell until it's ready"
23 # Loop until exit status 0 (success) given by Karaf shell
24 # Exit status 255 means the Karaf shell isn't open for SSH connections yet
25 until sshpass -p karaf ssh -p $KARAF_SHELL_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PreferredAuthentications=password karaf@localhost
27 echo "Karaf shell isn't ready yet, sleeping 5 seconds..."