1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

/usr/bin/iiab-support: Code cleaner

This commit is contained in:
root 2021-08-25 09:11:08 -04:00
parent 18838157eb
commit 6b91f1bb7a

View file

@ -62,10 +62,8 @@ fi
# echo -ne "\e[1mYour OpenVPN machine name is set to: \e[100m"
echo -ne "Your OpenVPN machine name (openvpn_handle) is: \e[32m"
echo -n "$handle" | sed "s/^\(['\"]\)\(.*\)\1$/\2/; s/ /_/g" # Avoid '-e' interpreting backlash escapes, to show var accurately! Double quote var to prevent field splitting (eats spaces)
echo -e "\e[0m" # Separate line also for trailing backslash in var
vpnip=$(ip a | grep tun0$ | awk '{print $2}')
echo -e "Your OpenVPN IP address (which can change) is: \e[32m$vpnip\e[0m\n"
echo -e "\e[0m\nYour OpenVPN IP address (which can change) is: \e[32m$vpnip\e[0m\n" # Separate line from above, also in case of trailing backslash in $handle
echo -e "\e[1mPlease type a descriptive OpenVPN machine name (openvpn_handle) such as:\n"
@ -80,7 +78,7 @@ if [ "$ans" = "" ]; then # (A) Simple! Writes to local_vars.yml a bit more o
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
sed -i "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml # Beware if user insists on input "\\", error is "sed: -e expression #1, char 39: unterminated `s' command"
else
echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml
fi