From 061bb2cf4f7dc71b83288ce24c783246eddd501d Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 00:21:34 -0400 Subject: [PATCH 1/7] Update and rename announcer to announcer.j2 --- .../templates/{announcer => announcer.j2} | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) rename roles/openvpn/templates/{announcer => announcer.j2} (71%) diff --git a/roles/openvpn/templates/announcer b/roles/openvpn/templates/announcer.j2 similarity index 71% rename from roles/openvpn/templates/announcer rename to roles/openvpn/templates/announcer.j2 index 26de78019..8c3f05482 100755 --- a/roles/openvpn/templates/announcer +++ b/roles/openvpn/templates/announcer.j2 @@ -3,23 +3,24 @@ HANDLE= UUID= -source /etc/iiab/iiab.env + if [ -f /etc/iiab/openvpn_handle ]; then HANDLE=`cat /etc/iiab/openvpn_handle` +else + source /etc/iiab/iiab.env + # DANGEROUS AS OF AUGUST 2018: + if [ -z "$HANDLE" ]; then + HANDLE=`cat /etc/iiab/iiab.ini | gawk \ + '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` + fi fi -# DANGEROUS AS OF AUGUST 2018: -#if [ -z "$HANDLE" ]; then -# HANDLE=`cat /etc/iiab/iiab.ini | gawk \ -# '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` -#fi if [ -f /etc/iiab/uuid ]; then - UUID=`cat /etc/iiab/uuid` + UUID=`cat /etc/iiab/uuid` fi # start the daemon which will serve the handle on demand # NEXT LINE OBSOLETE? August 2018 source /etc/init.d/functions SERVER=/usr/bin/ncat -# NEXT LINE OBSOLETE? August 2018 PID_FILE=/var/run/openvpn/announce.pid HANDLE=${HANDLE// /_} {% if is_debuntu %} From e3cb7f88b79dd23f475956beea05dda4ab69e900 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 00:35:48 -0400 Subject: [PATCH 2/7] Update main.yml --- roles/openvpn/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openvpn/tasks/main.yml b/roles/openvpn/tasks/main.yml index 9e27f95b5..0b265238e 100644 --- a/roles/openvpn/tasks/main.yml +++ b/roles/openvpn/tasks/main.yml @@ -41,7 +41,7 @@ - { src: 'client1.crt', dest: '/etc/openvpn/keys/client1.crt', mode: '0644' } - { src: 'client1.key', dest: '/etc/openvpn/keys/client1.key', mode: '0600' } - { src: 'announce', dest: '/etc/openvpn/scripts/announce', mode: '0755' } - - { src: 'announcer', dest: '/etc/openvpn/scripts/announcer', mode: '0755' } + - { src: 'announcer.j2', dest: '/etc/openvpn/scripts/announcer', mode: '0755' } - { src: 'silence', dest: '/etc/openvpn/scripts/silence', mode: '0755' } - { src: 'xscenet.conf.j2', dest: '/etc/openvpn/xscenet.conf', mode: '0644' } - { src: 'iiab-vpn.conf.in', dest: '/etc/openvpn/iiab-vpn.conf.in', mode: '0644' } From 212ad0d625638cc951662ab34ae9f07c828d2580 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 04:55:15 -0400 Subject: [PATCH 3/7] Update announcer.j2 --- roles/openvpn/templates/announcer.j2 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index 8c3f05482..8e3a01353 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -3,7 +3,6 @@ HANDLE= UUID= - if [ -f /etc/iiab/openvpn_handle ]; then HANDLE=`cat /etc/iiab/openvpn_handle` else @@ -14,18 +13,20 @@ else '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` fi fi +HANDLE=${HANDLE// /_} if [ -f /etc/iiab/uuid ]; then UUID=`cat /etc/iiab/uuid` fi + # start the daemon which will serve the handle on demand -# NEXT LINE OBSOLETE? August 2018 -source /etc/init.d/functions SERVER=/usr/bin/ncat -PID_FILE=/var/run/openvpn/announce.pid -HANDLE=${HANDLE// /_} +ID=`printf "HANDLE = %s|UUID = %s" $HANDLE $UUID` {% if is_debuntu %} -ID=`printf "HANDLE = %s|UUID = %s|" $HANDLE $UUID` +#ID=`printf "HANDLE = %s|UUID = %s|" $HANDLE $UUID` $SERVER -l -k -p1705 --exec "/bin/echo $ID" & {% else %} -daemon --pidfile=${PID_FILE} $SERVER "-l -k -p1705 --exec \"/usr/bin/echo $(printf 'HANDLE = %s|UUID = %s' $HANDLE $UUID)\"" & +source /etc/init.d/functions +PID_FILE=/var/run/openvpn/announce.pid +daemon --pidfile=${PID_FILE} $SERVER "-l -k -p1705 --exec \"/usr/bin/echo $ID\"" & +#daemon --pidfile=${PID_FILE} $SERVER "-l -k -p1705 --exec \"/usr/bin/echo $(printf 'HANDLE = %s|UUID = %s' $HANDLE $UUID)\"" & {% endif %} From c2649d4e92965ab8304dd9bbbb75accc09e8b15b Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 05:05:23 -0400 Subject: [PATCH 4/7] Update announcer.j2 --- roles/openvpn/templates/announcer.j2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index 8e3a01353..d9020b7e1 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -18,11 +18,12 @@ if [ -f /etc/iiab/uuid ]; then UUID=`cat /etc/iiab/uuid` fi -# start the daemon which will serve the handle on demand SERVER=/usr/bin/ncat ID=`printf "HANDLE = %s|UUID = %s" $HANDLE $UUID` -{% if is_debuntu %} #ID=`printf "HANDLE = %s|UUID = %s|" $HANDLE $UUID` + +# start the daemon which will serve the handle on demand +{% if is_debuntu %} $SERVER -l -k -p1705 --exec "/bin/echo $ID" & {% else %} source /etc/init.d/functions From 33f5fc601cc88891ef8844bcd4932d6689f68bfb Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 05:23:15 -0400 Subject: [PATCH 5/7] Update announcer.j2 --- roles/openvpn/templates/announcer.j2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index d9020b7e1..d33810b29 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -4,10 +4,13 @@ HANDLE= UUID= if [ -f /etc/iiab/openvpn_handle ]; then + # Option #0: might source directly from /etc/iiab/local_vars.yml in future + # Option #1 HANDLE=`cat /etc/iiab/openvpn_handle` else + # Option #2: dangerous to invoke hypothetical variables :( source /etc/iiab/iiab.env - # DANGEROUS AS OF AUGUST 2018: + # Option #3: WAS BUGGY IN AUGUST 2018, but safer now that relegated to #3 ? if [ -z "$HANDLE" ]; then HANDLE=`cat /etc/iiab/iiab.ini | gawk \ '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` From 59462b59c81fc6e4228e354f3949ea31a56fdbf0 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 05:27:12 -0400 Subject: [PATCH 6/7] Update announcer.j2 --- roles/openvpn/templates/announcer.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index d33810b29..c8296562f 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -10,7 +10,7 @@ if [ -f /etc/iiab/openvpn_handle ]; then else # Option #2: dangerous to invoke hypothetical variables :( source /etc/iiab/iiab.env - # Option #3: WAS BUGGY IN AUGUST 2018, but safer now that relegated to #3 ? + # Option #3: CAUSED FAILURES IN AUGUST 2018, invoking stale variable from /etc/iiab/iiab.ini, but safer now that relegated to #3 ? if [ -z "$HANDLE" ]; then HANDLE=`cat /etc/iiab/iiab.ini | gawk \ '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` From b516d475d05fed7179683d174599c7133fffc45d Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 14 Aug 2018 05:34:15 -0400 Subject: [PATCH 7/7] Update announcer.j2 --- roles/openvpn/templates/announcer.j2 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index c8296562f..8580112f9 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -1,14 +1,14 @@ #!/bin/bash -x -# small daemon to identify this machine to the openvpn server +# Small daemon to identify this machine to the OpenVPN server HANDLE= UUID= if [ -f /etc/iiab/openvpn_handle ]; then - # Option #0: might source directly from /etc/iiab/local_vars.yml in future + # Option #0: Might source directly from /etc/iiab/local_vars.yml in future # Option #1 HANDLE=`cat /etc/iiab/openvpn_handle` else - # Option #2: dangerous to invoke hypothetical variables :( + # Option #2: Dangerous to invoke hypothetical variables :( source /etc/iiab/iiab.env # Option #3: CAUSED FAILURES IN AUGUST 2018, invoking stale variable from /etc/iiab/iiab.ini, but safer now that relegated to #3 ? if [ -z "$HANDLE" ]; then @@ -23,9 +23,10 @@ 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` -# start the daemon which will serve the handle on demand +# Start the daemon which will serve the handle on demand {% if is_debuntu %} $SERVER -l -k -p1705 --exec "/bin/echo $ID" & {% else %}