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: handle missing file /etc/iiab/openvpn_handle

This commit is contained in:
A Holt 2019-05-12 02:55:44 -04:00 committed by GitHub
parent fdda195823
commit 320136cc69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,24 +1,24 @@
#!/bin/bash
handle1=$(grep "^openvpn_handle:.*" /etc/iiab/local_vars.yml | sed -e "s/^openvpn_handle://; s/^\s*//; s/\s*$//" | cut -d'"' -f2 | cut -d"'" -f2)
handle1=$(grep "^openvpn_handle:" /etc/iiab/local_vars.yml | sed -e "s/^openvpn_handle://; s/^\s*//; s/\s*$//" | cut -d'"' -f2 | cut -d"'" -f2)
echo -e "\n/etc/iiab/local_vars.yml source/master copy: $handle1"
if [ -f /etc/iiab/openvpn_handle ]; then
handle2=$(cat /etc/iiab/openvpn_handle)
echo -e "/etc/iiab/openvpn_handle for openvpn daemon: $handle2\n"
else
handle2=
echo -e "/etc/iiab/openvpn_handle for openvpn daemon: [FILE DOESN'T YET EXIST]\n"
fi
echo -e "\n/etc/iiab/local_vars.yml source/master copy: $handle1"
echo -e "/etc/iiab/openvpn_handle for openvpn daemon: $handle2\n"
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" != "" ]; then
if [ "$ans" != "" ] || [ ! -v handle2 ]; then
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
else
echo "openvpn_handle: $ans" >> /etc/iiab/local_vars.yml
fi
echo $ans > /etc/iiab/openvpn_handle
echo -e "\n\e[1mYour openvpn_handle was saved into both above files.\e[0m\n"
echo -e "\n\e[1mSAVED: openvpn_handle recorded into both above files.\e[0m\n"
else
if [ "$handle1" != "$handle2" ]; then
echo -e "\n\e[41mYou MUST specify an OpenVPN machine name (openvpn_handle) to resolve the above\e[0m"