mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	Cleaner regex's in iiab-support
This commit is contained in:
		
							parent
							
								
									b98c036d5f
								
							
						
					
					
						commit
						fac74e0fc9
					
				
					 1 changed files with 8 additions and 8 deletions
				
			
		
							
								
								
									
										16
									
								
								iiab-support
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								iiab-support
									
										
									
									
									
								
							| 
						 | 
					@ -6,7 +6,7 @@ INVENTORY="ansible_hosts"
 | 
				
			||||||
# openvpn_handle is stored in 2 files on disk, one slightly stripped down (from
 | 
					# 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
 | 
					# 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:
 | 
					# (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
 | 
					# 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-factory/blob/master/iiab#L79-L97
 | 
				
			||||||
# https://github.com/iiab/iiab/blob/master/roles/firmware/templates/iiab-check-firmware#L12
 | 
					# 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
 | 
					#if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -f /etc/iiab/openvpn_handle ] ); then
 | 
				
			||||||
# -v (below) checks if var's defined: equivalent to file existence test above
 | 
					# -v (below) checks if var's defined: equivalent to file existence test above
 | 
				
			||||||
if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -v handle2 ] ); then
 | 
					if [ "$ans" != "" ] || ( [ "$handle1" = "" ] && [ ! -v handle2 ] ); then
 | 
				
			||||||
    if grep -q '^openvpn_handle:' /etc/iiab/local_vars.yml; then
 | 
					    if grep -q '^openvpn_handle:\s' /etc/iiab/local_vars.yml; then
 | 
				
			||||||
        sed -i "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml
 | 
					        sed -i "s/^openvpn_handle:\s.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml
 | 
					        echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
| 
						 | 
					@ -52,12 +52,12 @@ else
 | 
				
			||||||
    echo -e "\n\e[1mWARNING: openvpn_handle remains unchanged in both above files.\e[0m\n"
 | 
					    echo -e "\n\e[1mWARNING: openvpn_handle remains unchanged in both above files.\e[0m\n"
 | 
				
			||||||
fi
 | 
					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"
 | 
					    echo -e "Your IIAB installation appears normal, with OpenVPN already installed...\n"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
    echo -e "Plz wait a few minutes as sshd, iiab-admin & OpenVPN are confirmed/installed...\n"
 | 
					    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
 | 
					    if grep -q '^openvpn_install:\s' /etc/iiab/local_vars.yml; then
 | 
				
			||||||
        sed -i "s/^openvpn_install:.*/openvpn_install: True/" /etc/iiab/local_vars.yml
 | 
					        sed -i "s/^openvpn_install:\s.*/openvpn_install: True/" /etc/iiab/local_vars.yml
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo "openvpn_install: True" >> /etc/iiab/local_vars.yml
 | 
					        echo "openvpn_install: True" >> /etc/iiab/local_vars.yml
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
| 
						 | 
					@ -76,8 +76,8 @@ else
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo -e "Now let's (re)enable OpenVPN...\n"
 | 
					echo -e "Now let's (re)enable OpenVPN...\n"
 | 
				
			||||||
if grep -q '^openvpn_enabled:' /etc/iiab/local_vars.yml; then
 | 
					if grep -q '^openvpn_enabled:\s' /etc/iiab/local_vars.yml; then
 | 
				
			||||||
    sed -i "s/^openvpn_enabled:.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml
 | 
					    sed -i "s/^openvpn_enabled:\s.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
    echo "openvpn_enabled: True" >> /etc/iiab/local_vars.yml
 | 
					    echo "openvpn_enabled: True" >> /etc/iiab/local_vars.yml
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue