From 52900ba3308f398af0f497582d1a2badbe71e683 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 12 May 2019 04:05:57 -0400 Subject: [PATCH] Mandate existence of /etc/iiab/openvpn_handle --- roles/openvpn/templates/iiab-support | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/roles/openvpn/templates/iiab-support b/roles/openvpn/templates/iiab-support index 68763083f..61c7f1593 100644 --- a/roles/openvpn/templates/iiab-support +++ b/roles/openvpn/templates/iiab-support @@ -11,16 +11,18 @@ fi 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" != "" ] || [ ! -v handle2 ]; then + +#if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -f /etc/iiab/openvpn_handle ] ); then +if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -v handle2 ] ); then # equivalent to above 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 + sed -i "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[1mSAVED: openvpn_handle recorded into both above files.\e[0m\n" else - if [ "$handle1" != "$handle2" ]; then + if [ "$handle1" != "$handle2" ]; then # sloppily (but conveniently here) bash treats "$handle2" as "" when var's not defined! echo -e "\n\e[41mYou MUST specify an OpenVPN machine name (openvpn_handle) to resolve the above\e[0m" echo -e "\e[41mnaming conflict. Please rerun to proceed.\e[0m\n" exit 1 @@ -33,7 +35,7 @@ if grep -q '^openvpn_install: True' /etc/iiab/local_vars.yml; then else echo -e "Please wait a few minutes as IIAB Stage 1 (1-prep) & OpenVPN are installed...\n" if grep -q '^openvpn_install:' /etc/iiab/local_vars.yml; then - sed -i -e "s/^openvpn_install:.*/openvpn_install: True/" /etc/iiab/local_vars.yml + sed -i "s/^openvpn_install:.*/openvpn_install: True/" /etc/iiab/local_vars.yml else echo "openvpn_install: True" >> /etc/iiab/local_vars.yml fi @@ -44,7 +46,7 @@ fi echo -e "Now let's (re)enable OpenVPN...\n" if grep -q '^openvpn_enabled:' /etc/iiab/local_vars.yml; then - sed -i -e "s/^openvpn_enabled:.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml + sed -i "s/^openvpn_enabled:.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml else echo "openvpn_enabled: True" >> /etc/iiab/local_vars.yml fi