From 5c2c13966adf610deeafb8ac3490b82b72e00b8d Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 23 Nov 2020 02:39:59 -0500 Subject: [PATCH 1/7] Clean/Shorten openvpn/templates/announcer.j2 --- roles/openvpn/templates/announcer.j2 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index bc71bb6c7..a18136fb6 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -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 From 998b147e0825864ed44c0d1da3e63a1186b5947d Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 23 Nov 2020 02:54:46 -0500 Subject: [PATCH 2/7] Explain var(s) set to "" when file(s) don't exist. So ' || true' is not nec. --- roles/openvpn/templates/announcer.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index a18136fb6..40eee858e 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -6,7 +6,7 @@ #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) # Set to "" if file doesn't exist + HANDLE=$(cat /etc/iiab/openvpn_handle) # Sets to "" if file doesn't exist (error is ok!) # Sourcing a variable from ~4 different places is a recipe for total confusion # (or worse!) Far better to make variable openvpn_handle and file @@ -28,7 +28,7 @@ #fi HANDLE=${HANDLE// /_} #if [ -f /etc/iiab/uuid ]; then - UUID=$(cat /etc/iiab/uuid) # Set to "" if file doesn't exist + UUID=$(cat /etc/iiab/uuid) # Sets to "" if file doesn't exist (error is ok!) #fi SERVER=/usr/bin/ncat From a5941bb0f3c86f07febc5e4fe2de849c1ed4e8a8 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 23 Nov 2020 03:22:58 -0500 Subject: [PATCH 3/7] openvpn/templates/announcer.j2: 1 line instead of 9 lines, if we mandate debuntu --- roles/openvpn/templates/announcer.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/openvpn/templates/announcer.j2 b/roles/openvpn/templates/announcer.j2 index 40eee858e..457ddd115 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -41,6 +41,8 @@ ID=$(echo "HANDLE = $HANDLE|UUID = $UUID") # Start the daemon which will serve the handle on demand {% if is_debuntu %} $SERVER -l -k -p1705 --exec "/bin/echo $ID" & +# 2020-11-23: USE 1 LINE INSTEAD OF 9 LINES, IF WE MANDATE debuntu: +#/usr/bin/ncat -l -k -p1705 --exec "/bin/echo HANDLE = $HANDLE|UUID = $UUID" & {% else %} source /etc/init.d/functions PID_FILE=/var/run/openvpn/announce.pid From bf3b9a6f176a515dad72962748f01784233a45f1 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 23 Nov 2020 03:32:51 -0500 Subject: [PATCH 4/7] openvpn/templates/announcer.j2: Clarify all handle spaces changed to underscores --- 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 457ddd115..7d55d305b 100755 --- a/roles/openvpn/templates/announcer.j2 +++ b/roles/openvpn/templates/announcer.j2 @@ -26,7 +26,7 @@ # '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'` # fi #fi -HANDLE=${HANDLE// /_} +HANDLE=${HANDLE// /_} # Change all spaces to underscores #if [ -f /etc/iiab/uuid ]; then UUID=$(cat /etc/iiab/uuid) # Sets to "" if file doesn't exist (error is ok!) #fi From edff5a5fa04afd7cef5ef23a81cdbb9e555fc910 Mon Sep 17 00:00:00 2001 From: Tim Moody Date: Mon, 23 Nov 2020 18:04:00 -0500 Subject: [PATCH 5/7] change read_library_xml defaults --- roles/pylibs/templates/iiab_lib.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/roles/pylibs/templates/iiab_lib.py b/roles/pylibs/templates/iiab_lib.py index afca02edf..2c8f0f43d 100644 --- a/roles/pylibs/templates/iiab_lib.py +++ b/roles/pylibs/templates/iiab_lib.py @@ -55,7 +55,7 @@ def get_zim_list(path): zim_versions[perma_ref] = zim_info # if there are multiples, last should win return files_processed, zim_versions -def read_library_xml(lib_xml_file, kiwix_exclude_attr=[""]): # duplicated from iiab-cmdsrv +def read_library_xml(lib_xml_file, kiwix_exclude_attr=["favicon"]): # duplicated from iiab-cmdsrv but changed ''' Read zim properties from library.xml Returns dict of library.xml and map of zim id to zim file name (under /library/zims) @@ -69,8 +69,7 @@ def read_library_xml(lib_xml_file, kiwix_exclude_attr=[""]): # duplicated from i path_to_id_map (dict): A dictionary that translates zim ids to physical names ''' - kiwix_exclude_attr.append("id") # don't include id - kiwix_exclude_attr.append("favicon") # don't include large favicon + kiwix_exclude_attr.append("id") # don't include id because is key zims_installed = {} path_to_id_map = {} try: From 7bed67ddcca590052b1bd89c8ff1421ffe9f551c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 23 Nov 2020 19:31:43 -0600 Subject: [PATCH 6/7] temp fix for #2585 with networkd-dispatcher/groovy,now 2.0.1-1 revert when fixed upstream --- roles/network/defaults/main.yml | 3 +++ roles/network/tasks/netplan.yml | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 03204958e..186eb08c5 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -88,6 +88,9 @@ gui_static_wan_ip: "unset" wondershaper_dspeed: "4096" wondershaper_upspeed: "1024" +# netplan +fix_dispatcher: True + # Unused # network_config_dir: /etc/network/interfaces.d diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 2ce2d5109..b103f3331 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -57,6 +57,12 @@ with_items: - "{{ netplan.stdout_lines }}" +- name: Replace networkd-dispatcher #2585 for "groovy" + get_url: + url: https://gitlab.com/craftyguy/networkd-dispatcher/-/raw/2.1/networkd-dispatcher + dest: /usr/bin/networkd-dispatcher + when: internet_available and fix_dispatcher and ansible_distribution_release == "groovy" + #- name: Supply netplan template # template: # dest: /etc/netplan/01-iiab-config.yaml From 8ae93cc8de74ff11c4c5fa596713105867aedc9a Mon Sep 17 00:00:00 2001 From: Tim Moody Date: Tue, 24 Nov 2020 09:22:54 -0500 Subject: [PATCH 7/7] allow icon to be included in zim cat --- roles/pylibs/templates/iiab_lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/pylibs/templates/iiab_lib.py b/roles/pylibs/templates/iiab_lib.py index 2c8f0f43d..84dee97e3 100644 --- a/roles/pylibs/templates/iiab_lib.py +++ b/roles/pylibs/templates/iiab_lib.py @@ -107,7 +107,7 @@ def rem_libr_xml(zim_id, kiwix_library_xml): if e.returncode != 2: # skip bogus file open error in kiwix-manage print(outp) -def add_libr_xml(kiwix_library_xml, zim_path, zimname, zimidx): +def add_libr_xml(kiwix_library_xml, zim_path, zimname, zimidx=None): ''' Add a zim to library.xml