mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	iiab-support output more vivid: ANSI/VT100 colors/highlighting
This commit is contained in:
		
							parent
							
								
									c1e5052722
								
							
						
					
					
						commit
						c8a8dd85bc
					
				
					 1 changed files with 21 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -30,8 +30,8 @@ read ans < /dev/tty
 | 
			
		|||
 | 
			
		||||
# BEHAVIOR LIKE ANSIBLE'S parsing of vars from .yml:
 | 
			
		||||
# (0) No need to remove hash/comments b/c it's live input here, unlike above.
 | 
			
		||||
# (1) sed: Remove outer spacing IF NEC, then...
 | 
			
		||||
# (2) sed: Remove 1 pair of matching outer quotes (IF NEC)
 | 
			
		||||
# (1) sed: Trim outer spacing IF NEC, then...
 | 
			
		||||
# (2) sed: Trim 1 pair of matching outer quotes (IF NEC)
 | 
			
		||||
# (3) Ansible vars can have non-string value null.  SEE /opt/iiab/iiab/test.yml
 | 
			
		||||
#     Here in bash, we focus only on string values e.g. "" empty string if nec.
 | 
			
		||||
# (4) When writing to disk, we aggressively overwrite such null var lines, e.g.
 | 
			
		||||
| 
						 | 
				
			
			@ -39,9 +39,10 @@ read ans < /dev/tty
 | 
			
		|||
 | 
			
		||||
ans=$(echo $ans | sed "s/^\s*//; s/\s*$//; s/^\(['\"]\)\(.*\)\1$/\2/")
 | 
			
		||||
 | 
			
		||||
# if ( [ "$ans" = "$handle" ] || [ "$ans" = "" ] ) && [ "$handle" != "" ]; then    # Overkill
 | 
			
		||||
if [ "$ans" = "" ] || [ "$ans" = "$handle" ]; then
 | 
			
		||||
    echo -e "\n\e[1mWARNING: openvpn_handle remains unchanged in /etc/iiab/local_vars.yml\e[0m\n"
 | 
			
		||||
if [ "$ans" = "" ]; then    # (A) Simple!  Writes to local_vars.yml a bit more than nec.
 | 
			
		||||
# if [ "$ans" = "" ] || [ "$ans" = "$handle" ]; then    # (B) Only write to disk when nec?
 | 
			
		||||
# if ( [ "$ans" = "" ] || [ "$ans" = "$handle" ] ) && [ "$handle" != "" ]; then    # (C) Overkill
 | 
			
		||||
    echo -e "\n        \e[100mopenvpn_handle REMAINS UNCHANGED IN /etc/iiab/local_vars.yml\e[0m\n"
 | 
			
		||||
else
 | 
			
		||||
    if grep -q '^openvpn_handle:' /etc/iiab/local_vars.yml; then
 | 
			
		||||
        sed -i "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +50,7 @@ else
 | 
			
		|||
        echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    echo -e "\n\e[1mSAVED YOUR NEW openvpn_handle to /etc/iiab/local_vars.yml\e[0m\n"
 | 
			
		||||
    echo -e "\n                     \e[7mSAVED TO: /etc/iiab/local_vars.yml\e[0m\n"
 | 
			
		||||
    handle=$ans;    # For display at bottom
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +122,6 @@ vpnip=$(ip a | grep tun0$ | awk '{print $2}')
 | 
			
		|||
if [ "$vpnip" != "" ]; then
 | 
			
		||||
    echo -e "\nYour OpenVPN IP address (which can change) is: \e[32m$vpnip\e[0m\n"
 | 
			
		||||
else
 | 
			
		||||
    echo -e "\n \e[41m       ERROR: OpenVPN IP address not ready - PLEASE TRY THE ABOVE TIPS        \e[0m\n"
 | 
			
		||||
    echo -e "\n\n \e[41m       ERROR: OpenVPN IP address not ready - PLEASE TRY THE ABOVE TIPS        \e[0m\n"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue