1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

Clean/Shorten openvpn/templates/announcer.j2

This commit is contained in:
A Holt 2020-11-23 02:39:59 -05:00 committed by GitHub
parent a98b4ec11d
commit 5c2c13966a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,12 @@
#!/bin/bash -x
# Small daemon to identify this machine to the OpenVPN server
HANDLE=
UUID=
if [ -f /etc/iiab/openvpn_handle ]; then
#HANDLE=
#UUID=
#if [ -f /etc/iiab/openvpn_handle ]; then
# Option #1: Source directly from /etc/iiab/local_vars.yml in future?
# Option #2
HANDLE=`cat /etc/iiab/openvpn_handle`
HANDLE=$(cat /etc/iiab/openvpn_handle) # Set to "" if file doesn't exist
# Sourcing a variable from ~4 different places is a recipe for total confusion
# (or worse!) Far better to make variable openvpn_handle and file
@ -25,15 +25,17 @@ if [ -f /etc/iiab/openvpn_handle ]; then
# HANDLE=`cat {{ iiab_ini_file }} | gawk \
# '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'`
# fi
fi
#fi
HANDLE=${HANDLE// /_}
if [ -f /etc/iiab/uuid ]; then
UUID=`cat /etc/iiab/uuid`
fi
#if [ -f /etc/iiab/uuid ]; then
UUID=$(cat /etc/iiab/uuid) # Set to "" if file doesn't exist
#fi
SERVER=/usr/bin/ncat
ID=`printf "HANDLE = %s|UUID = %s" $HANDLE $UUID`
# August 2018: Removal of trailing slash tested on Raspbian, Ubuntu 18.04 & Ubuntu 16.04
#ID=$(printf "HANDLE = %s|UUID = %s" $HANDLE $UUID)
#ID=$(echo "HANDLE = ${HANDLE}|UUID = ${UUID}")
ID=$(echo "HANDLE = $HANDLE|UUID = $UUID")
# August 2018: Removal of trailing '|' tested on Raspbian, Ubuntu 18.04 & Ubuntu 16.04
#ID=`printf "HANDLE = %s|UUID = %s|" $HANDLE $UUID`
# Start the daemon which will serve the handle on demand