diff --git a/roles/openvpn/templates/iiab-support b/roles/openvpn/templates/iiab-support index a31691338..68763083f 100644 --- a/roles/openvpn/templates/iiab-support +++ b/roles/openvpn/templates/iiab-support @@ -1,24 +1,24 @@ #!/bin/bash -handle1=$(grep "^openvpn_handle:.*" /etc/iiab/local_vars.yml | sed -e "s/^openvpn_handle://; s/^\s*//; s/\s*$//" | cut -d'"' -f2 | cut -d"'" -f2) +handle1=$(grep "^openvpn_handle:" /etc/iiab/local_vars.yml | sed -e "s/^openvpn_handle://; s/^\s*//; s/\s*$//" | cut -d'"' -f2 | cut -d"'" -f2) +echo -e "\n/etc/iiab/local_vars.yml source/master copy: $handle1" if [ -f /etc/iiab/openvpn_handle ]; then handle2=$(cat /etc/iiab/openvpn_handle) + echo -e "/etc/iiab/openvpn_handle for openvpn daemon: $handle2\n" else - handle2= + echo -e "/etc/iiab/openvpn_handle for openvpn daemon: [FILE DOESN'T YET EXIST]\n" fi -echo -e "\n/etc/iiab/local_vars.yml source/master copy: $handle1" -echo -e "/etc/iiab/openvpn_handle for openvpn daemon: $handle2\n" echo -en "\e[1mPlease type a descriptive OpenVPN machine name (openvpn_handle) such as:\n\n cape-town-school-36-rpi-2019-05-31\n\nOr hit [Enter] to keep the existing name:\e[0m " read ans < /dev/tty -if [ "$ans" != "" ]; then +if [ "$ans" != "" ] || [ ! -v handle2 ]; then if grep -q '^openvpn_handle:' /etc/iiab/local_vars.yml; then sed -i -e "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml else echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml fi echo $ans > /etc/iiab/openvpn_handle - echo -e "\n\e[1mYour openvpn_handle was saved into both above files.\e[0m\n" + echo -e "\n\e[1mSAVED: openvpn_handle recorded into both above files.\e[0m\n" else if [ "$handle1" != "$handle2" ]; then echo -e "\n\e[41mYou MUST specify an OpenVPN machine name (openvpn_handle) to resolve the above\e[0m"