diff --git a/iiab-support b/iiab-support index 9eee4fbd6..7896579eb 100755 --- a/iiab-support +++ b/iiab-support @@ -6,7 +6,7 @@ INVENTORY="ansible_hosts" # openvpn_handle is stored in 2 files on disk, one slightly stripped down (from # the other) due to Ansible. So we emulate Ansible's behavior, when reading from # (and later writing to) disk, removing outer cruft as explained on Lines 31-33: -handle1=$(grep "^openvpn_handle:" /etc/iiab/local_vars.yml | sed "s/^openvpn_handle://; s/^\s*//; s/\s*$//; s/^\(['\"]\)\(.*\)\1$/\2/") +handle1=$(grep "^openvpn_handle:\s" /etc/iiab/local_vars.yml | sed "s/^openvpn_handle:\s\+//; s/#.*//; s/\s*$//; s/^\(['\"]\)\(.*\)\1$/\2/") # 2021-08-17: bash scripts using default_vars.yml &/or local_vars.yml # https://github.com/iiab/iiab-factory/blob/master/iiab#L79-L97 # https://github.com/iiab/iiab/blob/master/roles/firmware/templates/iiab-check-firmware#L12 @@ -31,8 +31,8 @@ read ans < /dev/tty #if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -f /etc/iiab/openvpn_handle ] ); then # -v (below) checks if var's defined: equivalent to file existence test above if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -v handle2 ] ); then - if grep -q '^openvpn_handle:' /etc/iiab/local_vars.yml; then - sed -i "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml + if grep -q '^openvpn_handle:\s' /etc/iiab/local_vars.yml; then + sed -i "s/^openvpn_handle:\s.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml else echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml fi @@ -52,12 +52,12 @@ else echo -e "\n\e[1mWARNING: openvpn_handle remains unchanged in both above files.\e[0m\n" fi -if grep -q '^openvpn_installed: True\b' /etc/iiab/iiab_state.yml; then +if grep -q '^openvpn_installed:\s\+[tT]rue\b' /etc/iiab/iiab_state.yml; then echo -e "Your IIAB installation appears normal, with OpenVPN already installed...\n" else echo -e "Plz wait a few minutes as sshd, iiab-admin & OpenVPN are confirmed/installed...\n" - if grep -q '^openvpn_install:' /etc/iiab/local_vars.yml; then - sed -i "s/^openvpn_install:.*/openvpn_install: True/" /etc/iiab/local_vars.yml + if grep -q '^openvpn_install:\s' /etc/iiab/local_vars.yml; then + sed -i "s/^openvpn_install:\s.*/openvpn_install: True/" /etc/iiab/local_vars.yml else echo "openvpn_install: True" >> /etc/iiab/local_vars.yml fi @@ -76,8 +76,8 @@ else fi echo -e "Now let's (re)enable OpenVPN...\n" -if grep -q '^openvpn_enabled:' /etc/iiab/local_vars.yml; then - sed -i "s/^openvpn_enabled:.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml +if grep -q '^openvpn_enabled:\s' /etc/iiab/local_vars.yml; then + sed -i "s/^openvpn_enabled:\s.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml else echo "openvpn_enabled: True" >> /etc/iiab/local_vars.yml fi