„setup_tunnel.sh“ ändern

This commit is contained in:
iwonder 2021-03-01 21:37:34 +01:00
parent ae130004ff
commit 62eadd676f

View File

@ -1,5 +1,5 @@
#!/bin/bash
set -e
#set -x
OS_KEYPAIR_NAME=ovh_$(hostname -s)
OS_MACHINE_NAME=gbv
SERVER_RUNNING=false
@ -25,11 +25,11 @@ source openrc.sh
#
# Prerequisites
#
if ! command -v ipcalc-ng &>/dev/null
then
echo >&2 "ipcalc-ng is required. Exiting."
exit 1
fi
#if ! command -v ipcalc-ng &>/dev/null
#then
#echo >&2 "ipcalc-ng is required. Exiting."
#exit 1
#fi
if ! command -v openstack &>/dev/null
then
echo >&2 "openstack is required. Exiting."
@ -69,7 +69,7 @@ openstack keypair list|grep -q $OS_KEYPAIR_NAME
RESULT=$?
if [ $RESULT -eq 1 ]; then
echo "Uploading SSH key to OpenStack..."
nova keypair-add --pub_key ~/.ssh/id_ovh.pub $OS_KEYPAIR_NAME
nova keypair-add --pub-key ~/.ssh/id_ovh.pub $OS_KEYPAIR_NAME
fi
#
# Get flavor and image
@ -94,7 +94,8 @@ SERVER_IPS="$(openstack server show gbv -f json|jq -r .addresses)"
SERVER_IPS="${SERVER_IPS##Ext-Net=}"
read -a SERVER_IPS <<< $SERVER_IPS
SERVER_IPS[0]="${SERVER_IPS[0]%%,}"
ipcalc-ng -c4 ${SERVER_IPS[0]} &>/dev/null
#ipcalc-ng -c4 ${SERVER_IPS[0]} &>/dev/null
grep -q '\.' <<< ${SERVER_IPS[0]}
IS_IPV4=$?
if [ $IS_IPV4 -eq 0 ]
then