Add Carbon Packer config
[integration/packaging.git] / rpm / connect.sh
1 #!/usr/bin/env sh
2 # Connect to ODL Karaf shell. Mostly used for testing.
3
4 # Port that the Karaf shell listens on
5 KARAF_SHELL_PORT=8101
6
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
15         else
16             echo "Failed to install sshpass and EPEL, giving up"
17             exit 1
18         fi
19     fi
20 fi
21
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
26 do
27     echo "Karaf shell isn't ready yet, sleeping 5 seconds..."
28     sleep 5
29 done