Merge pull request #16163 from stintel/openvswitch
authorStijn Tintel <stijn@linux-ipv6.be>
Mon, 26 Jul 2021 15:21:55 +0000 (18:21 +0300)
committerGitHub <noreply@github.com>
Mon, 26 Jul 2021 15:21:55 +0000 (18:21 +0300)
openvswitch: allow complex port configurations

52 files changed:
lang/python/python-dateutil/Makefile
lang/python/python-requests/Makefile
lang/python/python-requests/patches/0001-idna-dependency-bump.patch [deleted file]
lang/python/python-requests/patches/0002-idna-dependency-bump.patch [deleted file]
libs/alsa-lib/Makefile
libs/librouteros/Makefile
libs/librouteros/patches/010-no-doc.patch [new file with mode: 0644]
net/dnsproxy/Makefile
net/dnsproxy/files/dnsproxy.config [new file with mode: 0644]
net/dnsproxy/files/dnsproxy.init [new file with mode: 0644]
net/hs20/Makefile
net/iperf/Makefile
net/iperf/patches/0003-fix-non-ipv6-builds.patch [deleted file]
net/iperf/patches/010-libcxx.patch [deleted file]
net/iperf/patches/020-math.patch [deleted file]
net/lksctp-tools/Makefile
net/lksctp-tools/patches/010-build-fix-netinet-sctp.h-not-to-be-installed.patch [deleted file]
net/travelmate/Makefile
net/travelmate/files/chs-hotel.login
net/travelmate/files/db-bahn.login
net/travelmate/files/generic-user-pass.login
net/travelmate/files/h-hotels.login
net/travelmate/files/julianahoeve.login [new file with mode: 0755]
net/travelmate/files/telekom.login [new file with mode: 0755]
net/travelmate/files/travelmate.init
net/travelmate/files/travelmate.mail
net/travelmate/files/travelmate.sh
net/travelmate/files/travelmate.vpn
net/travelmate/files/travelmate_ntp.hotplug
net/travelmate/files/vodafone.login [new file with mode: 0755]
net/travelmate/files/wifionice.login
utils/bash/Makefile
utils/bash/patches/101-bash51-001.patch [deleted file]
utils/bash/patches/102-bash51-002.patch [deleted file]
utils/bash/patches/103-bash51-003.patch [deleted file]
utils/bash/patches/104-bash51-004.patch [deleted file]
utils/bluez/Makefile
utils/bluez/patches/201-readline.patch
utils/bluez/patches/205-refresh_adv_manager_for_non-LE_devices.patch
utils/canutils/Makefile
utils/cryptsetup/Makefile
utils/ctop/Makefile
utils/rrdtool1/Makefile
utils/rrdtool1/patches/050-no-doc.patch [new file with mode: 0644]
utils/spi-tools/Makefile
utils/uvol/Makefile
utils/uvol/files/common.sh [new file with mode: 0644]
utils/uvol/files/lvm.sh
utils/uvol/files/ubi.sh
utils/yara/Makefile
utils/yara/patches/010-openssl.patch [deleted file]
utils/yq/Makefile

index 7c8de816788d3b648d87a44233fb2b31735ad933..394a307b6fd29708b2ea5b3722e2e34db27a5142 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=python-dateutil
-PKG_VERSION:=2.8.1
-PKG_RELEASE:=3
+PKG_VERSION:=2.8.2
+PKG_RELEASE:=1
 PKG_LICENSE:=BSD-2-Clause
 
 PYPI_NAME:=$(PKG_NAME)
-PKG_HASH:=73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c
+PKG_HASH:=0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86
 PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
 
 HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=setuptools-scm
index a32e590a551fe9e42a37bc56d91ba98e3dba6f4c..5853897beee9ab025199239178f05eaee901b1c0 100644 (file)
@@ -8,8 +8,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=python-requests
-PKG_VERSION:=2.25.1
-PKG_RELEASE:=2
+PKG_VERSION:=2.26.0
+PKG_RELEASE:=1
 
 PKG_MAINTAINER:=Josef Schlehofer <josef.schlehofer@nic.cz>, Alexandru Ardelean <ardeleanalex@gmail.com>
 PKG_LICENSE:=Apache-2.0
@@ -17,7 +17,7 @@ PKG_LICENSE_FILES:=LICENSE
 PKG_CPE_ID:=cpe:/a:python-requests:requests
 
 PYPI_NAME:=requests
-PKG_HASH:=27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804
+PKG_HASH:=b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7
 
 include ../pypi.mk
 include $(INCLUDE_DIR)/package.mk
diff --git a/lang/python/python-requests/patches/0001-idna-dependency-bump.patch b/lang/python/python-requests/patches/0001-idna-dependency-bump.patch
deleted file mode 100644 (file)
index 72ffb45..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-From 9484e13c7da927119fe82794bb5571cec144b6d7 Mon Sep 17 00:00:00 2001
-From: Naor Livne <naorlivne@gmail.com>
-Date: Fri, 1 Jan 2021 14:31:14 +0200
-Subject: [PATCH 1/2] bump idna has version 3.0 was released
-
-Fixes issue (https://github.com/psf/requests/issues/5710):
-pkg_resources.ContextualVersionConflict: (idna 3.0 (/usr/lib/python3.9/site-packages), Requirement.parse('idna<3,>=2.5'), {'requests'})
-Origin of this patch:
-https://github.com/psf/requests/pull/5711
-
----
- setup.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/setup.py
-+++ b/setup.py
-@@ -43,7 +43,7 @@ packages = ['requests']
- requires = [
-     'chardet>=3.0.2,<5',
--    'idna>=2.5,<3',
-+    'idna>=2.5,<4',
-     'urllib3>=1.21.1,<1.27',
-     'certifi>=2017.4.17'
diff --git a/lang/python/python-requests/patches/0002-idna-dependency-bump.patch b/lang/python/python-requests/patches/0002-idna-dependency-bump.patch
deleted file mode 100644 (file)
index 9df2ddc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-From d3e00a4958af046879f24de365d5589d861ea6ef Mon Sep 17 00:00:00 2001
-From: Naor Livne <naorlivne@gmail.com>
-Date: Tue, 5 Jan 2021 16:31:15 +0200
-Subject: [PATCH 2/2] Update setup.py
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Co-authored-by: MickaĆ«l Schoentgen <contact@tiger-222.fr>
----
- setup.py | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/setup.py
-+++ b/setup.py
-@@ -43,7 +43,8 @@ packages = ['requests']
- requires = [
-     'chardet>=3.0.2,<5',
--    'idna>=2.5,<4',
-+    'idna>=2.5,<3 ; python_version < "3"',
-+    'idna>=2.5,<4 ; python_version >= "3"',
-     'urllib3>=1.21.1,<1.27',
-     'certifi>=2017.4.17'
index 691ab4fbfe7ba15f7fe3ef9c40649043c3db7bbb..ffdba1103acead8cab86c2a3d112e7701beab3d4 100644 (file)
@@ -100,10 +100,13 @@ define Package/alsa-lib/install
                $(PKG_INSTALL_DIR)/usr/lib/libatopology.so.* \
                $(1)/usr/lib/
 
-       $(INSTALL_DIR) $(1)/usr/share/alsa/{cards,pcm}
+       $(INSTALL_DIR) $(1)/usr/share/alsa/{cards,ctl,pcm}
        $(INSTALL_DATA) \
                $(PKG_INSTALL_DIR)/usr/share/alsa/alsa.conf \
                $(1)/usr/share/alsa/
+       $(INSTALL_DATA) \
+               $(PKG_INSTALL_DIR)/usr/share/alsa/ctl/* \
+               $(1)/usr/share/alsa/ctl/
        $(INSTALL_DATA) \
                $(PKG_INSTALL_DIR)/usr/share/alsa/pcm/* \
                $(1)/usr/share/alsa/pcm/
index 2908de07749e8f88dfaf7fc610396848013f71aa..1d5a6b454db44c38a1b365cd1a1170173ef57517 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=librouteros
 PKG_SOURCE_DATE:=2018-07-19
 PKG_SOURCE_VERSION:=c485c777ffbbbd87c3d72d843af36ba016803cae
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_MAINTAINER:=Sven Roederer <devel-sven@geroedel.de>
 PKG_LICENSE:=ISC
diff --git a/libs/librouteros/patches/010-no-doc.patch b/libs/librouteros/patches/010-no-doc.patch
new file mode 100644 (file)
index 0000000..8a07e30
--- /dev/null
@@ -0,0 +1,7 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,3 +1,3 @@
+-SUBDIRS = src doc
++SUBDIRS = src
+ README:       README.md
index 3b5557b52d06f52af5f2f3d40ef52774a2b4e2b1..abb292b9639d84e60e201e859079d5cf287138fc 100644 (file)
@@ -5,12 +5,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsproxy
-PKG_VERSION:=0.38.2
+PKG_VERSION:=0.39.0
 PKG_RELEASE:=$(AUTORELESE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=cc240be1e6975cc782155427f45a3753beb647d0de44f2e9f734486fc19db379
+PKG_HASH:=00cf9978670e51be14cab262638735321afa917c3b4f46c0c5a189731ee124bf
 
 PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
 PKG_LICENSE:=Apache-2.0
@@ -34,6 +34,7 @@ define Package/dnsproxy
   TITLE:=Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support
   URL:=https://github.com/AdguardTeam/dnsproxy
   DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
+  USERID:=dnsproxy=411:dnsproxy=411
 endef
 
 define Package/dnsproxy/description
@@ -42,5 +43,14 @@ define Package/dnsproxy/description
   work as a DNS-over-HTTPS, DNS-over-TLS or DNS-over-QUIC server.
 endef
 
+define Package/dnsproxy/install
+       $(call GoPackage/Package/Install/Bin,$(1))
+
+       $(INSTALL_DIR) $(1)/etc/config/
+       $(INSTALL_CONF) $(CURDIR)/files/dnsproxy.config $(1)/etc/config/dnsproxy
+       $(INSTALL_DIR) $(1)/etc/init.d/
+       $(INSTALL_BIN) $(CURDIR)/files/dnsproxy.init $(1)/etc/init.d/dnsproxy
+endef
+
 $(eval $(call GoBinPackage,dnsproxy))
 $(eval $(call BuildPackage,dnsproxy))
diff --git a/net/dnsproxy/files/dnsproxy.config b/net/dnsproxy/files/dnsproxy.config
new file mode 100644 (file)
index 0000000..a9fa020
--- /dev/null
@@ -0,0 +1,41 @@
+
+# For documents, please see https://github.com/AdguardTeam/dnsproxy#usage
+
+config dnsproxy 'global'
+       option enabled '0'
+       option listen_addr '127.0.0.1'
+       option listen_port '5353'
+       option log_file ''
+       option all_servers '0'
+       option fastest_addr '0'
+       option insecure '0'
+       option ipv6_disabled '0'
+       option max_go_routines ''
+       option rate_limit ''
+       option refuse_any '0'
+       option udp_buf_size ''
+       option verbose '0'
+
+config dnsproxy 'bogus_nxdomain'
+       list ip_addr ''
+
+config dnsproxy 'cache'
+       option enabled '0'
+       option cache_optimistic '0'
+       option size '65535'
+       option min_ttl ''
+       option max_ttl ''
+
+config dnsproxy 'dns64'
+       option enabled '0'
+       option dns64_prefix '64:ff9b::'
+
+config dnsproxy 'edns'
+       option enabled '0'
+       option edns_addr ''
+
+config dnsproxy 'servers'
+       list bootstrap 'tls://8.8.8.8'
+       list fallback 'tls://9.9.9.9'
+       list upstream 'tls://1.1.1.1'
+
diff --git a/net/dnsproxy/files/dnsproxy.init b/net/dnsproxy/files/dnsproxy.init
new file mode 100644 (file)
index 0000000..9ac2751
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
+
+USE_PROCD=1
+START=90
+
+CONF="dnsproxy"
+PROG="/usr/bin/dnsproxy"
+
+is_enabled() {
+       local enabled
+       config_get enabled "$1" "$2" "0"
+       if [ "$enabled" -eq "1" ]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+is_empty() {
+       local empty
+       config_get empty "$1" "$2" $3
+       if [ -z "$empty" ]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+append_param() {
+       procd_append_param command "$1" $2
+}
+
+append_param_arg() {
+       local value
+       config_get value "$1" "$2" $4
+       [ -n "$value" ] && append_param "$3" "$value"
+}
+
+append_param_bool() {
+       is_enabled "$1" "$2" && append_param "--${2//_/-}"
+}
+
+load_config_arg() {
+       append_param_bool "$1" "all_servers"
+       append_param_bool "$1" "fastest_addr"
+       append_param_bool "$1" "insecure"
+       append_param_bool "$1" "ipv6_disabled"
+       append_param_bool "$1" "refuse_any"
+       append_param_bool "$1" "verbose"
+}
+
+load_config_list() {
+       is_empty "bogus_nxdomain" "ip_addr" || config_list_foreach "bogus_nxdomain" "ip_addr" "append_param '--bogus-nxdomain'"
+
+       for i in "bootstrap" "fallback" "upstream"; do
+               is_empty "servers" "$i" || config_list_foreach "servers" "$i" "append_param '--$i'"
+       done
+}
+
+load_config_param() {
+       append_param_arg "global" "listen_addr" "--listen" "127.0.0.1"
+       append_param_arg "global" "listen_port" "--port" "5353"
+       append_param_arg "global" "log_file" "--output"
+       append_param_arg "global" "max_go_routines" "--max-go-routines"
+       append_param_arg "global" "rate_limit" "--ratelimit"
+       append_param_arg "global" "udp_buf_size" "--udp-buf-size"
+
+       is_enabled "cache" "enabled" && {
+               append_param "--cache"
+               append_param_bool "cache" "cache_optimistic"
+               append_param_arg "cache" "size" "--cache-size"
+               append_param_arg "cache" "min_ttl" "--cache-min-ttl"
+               append_param_arg "cache" "max_ttl" "--cache-max-ttl"
+       }
+
+       is_enabled "dns64" "enabled" && {
+               append_param "--dns64"
+               append_param_arg "dns64" "dns64_prefix" "--dns64-prefix"
+       }
+
+       is_enabled "edns" "enabled" && {
+               append_param "--edns"
+               append_param_arg "edns" "edns_addr" "--edns-addr"
+       }
+}
+
+start_service() {
+       config_load "$CONF"
+
+       is_enabled "global" "enabled" || exit 1
+
+       procd_open_instance "$CONF"
+       procd_set_param command "$PROG"
+
+       load_config_arg "global"
+       load_config_list
+       load_config_param
+
+       procd_set_param respawn
+       procd_set_param stdout 1
+       procd_set_param stderr 1
+       procd_set_param user dnsproxy
+
+       procd_close_instance
+}
+
+reload_service() {
+       stop
+       start
+}
+
+service_triggers() {
+       procd_add_reload_trigger "$CONF"
+}
index 330fb335ac8dddcbd0a92bc71dfdaf97e4a6d7dd..e244f50a1c3abf0509524fa55e35b6ada550495c 100644 (file)
@@ -12,6 +12,7 @@ PKG_SOURCE_NAME:=hostapd
 PKG_MIRROR_HASH:=1b2a4947034142587a3f81eac2ea27dd64650e77f8943d973623b47533be2393
 PKG_MIRROR_VERSION:=$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION))
 PKG_SOURCE:=$(PKG_SOURCE_NAME)-$(PKG_MIRROR_VERSION).tar.xz
+PKG_SOURCE_SUBDIR:=$(PKG_SOURCE_NAME)-$(PKG_MIRROR_VERSION)
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_SOURCE_NAME)-$(PKG_MIRROR_VERSION)
 
 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
index 5757875966d4a46bc50dba076974ec12cb262742..d071d0c03158826f157d9f1683e3bfb1072bc79b 100644 (file)
@@ -8,11 +8,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iperf
-PKG_VERSION:=2.0.13
-PKG_RELEASE:=3
+PKG_VERSION:=2.1.3
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_HASH:=c88adec966096a81136dda91b4bd19c27aae06df4d45a7f547a8e50d723778ad
+PKG_HASH:=dfe2197e2842fe9c9d9677bf1cb20a5a9ccfcb9a9de79f9927c39f73204ba003
 PKG_SOURCE_URL:=@SF/iperf2
 
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
diff --git a/net/iperf/patches/0003-fix-non-ipv6-builds.patch b/net/iperf/patches/0003-fix-non-ipv6-builds.patch
deleted file mode 100644 (file)
index c6afa3e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/src/Listener.cpp
-+++ b/src/Listener.cpp
-@@ -723,6 +723,7 @@ int Listener::L2_setup (void) {
-     // Now optimize packet flow up the raw socket
-     // Establish the flow BPF to forward up only "connected" packets to this raw socket
-+#ifdef HAVE_IPV6
-     if (l->sa_family == AF_INET6) {
- #ifdef HAVE_IPV6
-       struct in6_addr *v6peer = SockAddr_get_in6_addr(&server->peer);
-@@ -740,6 +741,9 @@ int Listener::L2_setup (void) {
-       return -1;
- #endif /* HAVE_IPV6 */
-     } else {
-+#else
-+    {
-+#endif
-       rc = SockAddr_v4_Connect_BPF(server->mSock, ((struct sockaddr_in *)(l))->sin_addr.s_addr, ((struct sockaddr_in *)(p))->sin_addr.s_addr, ((struct sockaddr_in *)(l))->sin_port, ((struct sockaddr_in *)(p))->sin_port);
-       WARN_errno( rc == SOCKET_ERROR, "l2 connect ip bpf");
-     }
diff --git a/net/iperf/patches/010-libcxx.patch b/net/iperf/patches/010-libcxx.patch
deleted file mode 100644 (file)
index cf01242..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
---- a/config.h.in
-+++ b/config.h.in
-@@ -360,7 +360,9 @@
- #undef _REENTRANT
- /* */
-+#ifndef __cplusplus
- #undef bool
-+#endif
- /* Define to empty if `const' does not conform to ANSI C. */
- #undef const
diff --git a/net/iperf/patches/020-math.patch b/net/iperf/patches/020-math.patch
deleted file mode 100644 (file)
index da255c2..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---- a/src/pdfs.c
-+++ b/src/pdfs.c
-@@ -80,7 +80,7 @@ float box_muller(void) {
-           fprintf(stderr, "pdf box_muller() rand() error\n");
-           return 0;
-       } else {
--          w = sqrt( (-2.0 * log( w ) ) / w );
-+          w = sqrt( (-2.0 * logf( w ) ) / w );
-           y1 = x1 * w;
-           y2 = x2 * w;
-       }
-@@ -93,8 +93,8 @@ float normal(float mean, float variance)
- }
- float lognormal(float mu, float sigma) {
--    float phi = sqrt((mu * mu) + (sigma * sigma));
--    float mu_prime = log(((mu * mu)/phi));
--    float sigma_prime = sqrt(log((phi * phi)/(mu * mu)));
--    return (exp(normal(mu_prime,sigma_prime)));
-+    float phi = sqrtf((mu * mu) + (sigma * sigma));
-+    float mu_prime = logf(((mu * mu)/phi));
-+    float sigma_prime = sqrtf(logf((phi * phi)/(mu * mu)));
-+    return (expf(normal(mu_prime,sigma_prime)));
- }
index a57c336d68cac90b12afa882c63be32096a487e6..1cb4ea9731fdaf31bc256cdd79d1b1e2be9652b7 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=lksctp-tools
-PKG_VERSION:=1.0.18
-PKG_RELEASE:=1
+PKG_VERSION:=1.0.19
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/sctp/lksctp-tools/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=3e9ab5b3844a8b65fc8152633aafe85f406e6da463e53921583dfc4a443ff03a
+PKG_HASH:=9251b1368472fb55aaeafe4787131bdde4e96758f6170620bc75b638449cef01
 
 PKG_MAINTAINER:=
 PKG_LICENSE:=GPL-2.0
diff --git a/net/lksctp-tools/patches/010-build-fix-netinet-sctp.h-not-to-be-installed.patch b/net/lksctp-tools/patches/010-build-fix-netinet-sctp.h-not-to-be-installed.patch
deleted file mode 100644 (file)
index 389138a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-From 378560050a8f93786c590cc99a55461666205b61 Mon Sep 17 00:00:00 2001
-From: Xin Long <lucien.xin@gmail.com>
-Date: Fri, 24 Aug 2018 01:13:32 +0800
-Subject: [PATCH] build: fix netinet/sctp.h not to be installed
-
-After libcnetinet_HEADERS was set to sctp.h.in, netinet/sctp.h can
-no longer be installed into ${includedir}.
-
-Since "AC_CONFIG_HEADERS([src/include/netinet/sctp.h])" is already
-added into configure.ac, there's no need to generate sctp.h by
-automake.
-
-So we simply set libcnetinet_HEADERS back to sctp.h.
-
-Fixes: 9607dd85e70a ("netinet/sctp.h: dynamically build based on system setup")
-Signed-off-by: Xin Long <lucien.xin@gmail.com>
-Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
----
- src/include/netinet/Makefile.am | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
---- a/src/include/netinet/Makefile.am
-+++ b/src/include/netinet/Makefile.am
-@@ -11,5 +11,4 @@ libcnetinetdir = $(includedir)/netinet
- # API.
- include_HEADERS =
--libcnetinet_HEADERS = sctp.h.in
--BUILT_SOURCES = sctp.h
-+libcnetinet_HEADERS = sctp.h
index 8a31e5e16763ced3238811309a92ae94a956d2cc..00caaf467bd362806fb7735bf017822e35ae3e11 100644 (file)
@@ -6,8 +6,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=travelmate
-PKG_VERSION:=2.0.3
-PKG_RELEASE:=2
+PKG_VERSION:=2.0.4
+PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 3b23f467c501fae1b7270f13e02ea219349cc594..905824ad79680e7a71b1c3c101441c2e7d346e99 100755 (executable)
@@ -1,43 +1,40 @@
 #!/bin/sh
-# captive portal auto-login script for german chs hotels
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# captive portal auto-login script for chs hotels (DE)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2181,3040
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
        . "/lib/functions.sh"
 fi
 
 trm_domain="hotspot.internet-for-guests.com"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
 trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
 trm_fetch="$(command -v curl)"
 
-# initial get request to receive & extract valid security tokens
+# get security tokens
 #
-"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi"
-if [ -r "/tmp/${trm_domain}.cookie" ]
-then
-       lg_id="$(awk '/LGNSID/{print $7}' "/tmp/${trm_domain}.cookie")"
-       ta_id="$(awk '/ta_id/{print $7}' "/tmp/${trm_domain}.cookie")"
-       cl_id="$(awk '/cl_id/{print $7}' "/tmp/${trm_domain}.cookie")"
-       rm -f "/tmp/${trm_domain}.cookie"
-else
-       exit 2
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi"
+lg_id="$(awk '/LGNSID/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+ta_id="$(awk '/ta_id/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+cl_id="$(awk '/cl_id/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${lg_id}" ] || [ -z "${ta_id}" ] || [ -z "${cl_id}" ]; then
+       exit 1
 fi
 
-# final post request/login with valid session cookie/security token
+# final login request
 #
-if [ -n "${lg_id}" ] && [ -n "${ta_id}" ] && [ -n "${cl_id}" ]
-then
-       "${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/logon/cgi/index.cgi" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: LGNSID=${lg_id}; lang=en_US; use_mobile_interface=0; ta_id=${ta_id}; cl_id=${cl_id}" --data "accept_termsofuse=&freeperperiod=1&device_infos=1125:2048:1152:2048" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi"
-else
-       exit 3
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/logon/cgi/index.cgi" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: LGNSID=${lg_id}; lang=en_US; use_mobile_interface=0; ta_id=${ta_id}; cl_id=${cl_id}" --data "accept_termsofuse=&freeperperiod=1&device_infos=1125:2048:1152:2048" --output /dev/null "https://${trm_domain}/logon/cgi/index.cgi"
+if [ "${?}" != "0" ]; then
+       exit 2
 fi
index a0ab505b50929d111247cd4b0d48002783b690bc..2b4bf30f5223ced9299e5e638ccca3e53db7c6dc 100755 (executable)
@@ -1,65 +1,49 @@
 #!/bin/sh
-# captive portal auto-login script for german DB hotspots via portal login API
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# captive portal auto-login script for DB hotspots (DE)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2181,3040
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
        . "/lib/functions.sh"
 fi
 
 trm_domain="wifi.bahn.de"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
 trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
 trm_fetch="$(command -v curl)"
 
-# initial get request to receive all header information
-#
-"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}"
-
-# extract the session cookie and the hotspot location
+# get all header information
 #
-if [ -s "/tmp/${trm_domain}.cookie" ]
-then
-       sec_token="$(awk 'BEGIN{FS="[ ;]"}/^Set-Cookie:/{print $2}' "/tmp/${trm_domain}.cookie")"
-       location="$(awk '/^Location:/{print $2}' "/tmp/${trm_domain}.cookie")"
-       rm -f "/tmp/${trm_domain}.cookie"
-else
-       exit 2
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}"
+sec_token="$(awk 'BEGIN{FS="[ ;]"}/^Set-Cookie:/{print $2}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+location="$(awk '/^Location:/{print $2}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${sec_token}" ] || [ -z "${location}" ]; then
+       exit 1
 fi
 
 # post request to subscribe to the portal API
 #
-if [ -n "${sec_token}" ] && [ -n "${location}" ]
-then
-       "${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent  --connect-timeout $((trm_maxwait/6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --header "Cookie: ${sec_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" --output /dev/null "https://${trm_domain}/portal_api.php"
-else
-       exit 3
-fi
-
-# extract additional login and password information from the portal API
-#
-if [ -s "/tmp/${trm_domain}.cookie" ]
-then
-       login="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $12}' "/tmp/${trm_domain}.cookie")"
-       password="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $16}' "/tmp/${trm_domain}.cookie")"
-       rm -f "/tmp/${trm_domain}.cookie"
-else
-       exit 4
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait / 6)) --include --cookie-jar "/tmp/${trm_domain}.cookie" --header "Cookie: ${sec_token}" --data "action=subscribe&type=one&connect_policy_accept=false&user_login=&user_password=&user_password_confirm=&email_address=&prefix=&phone=&policy_accept=false&gender=&interests=" --output /dev/null "https://${trm_domain}/portal_api.php"
+login="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $12}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+password="$(awk 'BEGIN{FS="[\"]"}/^\{\"info/{print $16}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${login}" ] && [ -z "${password}" ]; then
+       exit 2
 fi
 
 # final post request to authenticate to the portal API
 #
-if [ -n "${login}" ] && [ -n "${password}" ]
-then
-       "${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: ${sec_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false" "https://${trm_domain}/portal_api.php"
-else
-       exit 5
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${location}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: ${sec_token}" --data "action=authenticate&login=${login}&password=${password}&policy_accept=false&from_ajax=true&wispr_mode=false" "https://${trm_domain}/portal_api.php"
+if [ "${?}" != "0" ]; then
+       exit 3
 fi
index 60c3b5a92c762a65108ab8e69960bfcee5bbf9f0..687a183589326203de8a7e32a23b51b51795d699 100755 (executable)
@@ -1,35 +1,32 @@
 #!/bin/sh
 # captive portal auto-login script template with credentials as parameters
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2039,3040
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
        . "/lib/functions.sh"
 fi
 
-trm_domain="example.com"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
-trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
-trm_fetch="$(command -v curl)"
-
 user="${1}"
 password="${2}"
 success="Thank you!"
+trm_domain="example.com"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
+trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
+trm_fetch="$(command -v curl)"
 
 # login with credentials
 #
-response="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --data "username=${user}&password=${password}" --header "Content-Type:application/x-www-form-urlencoded" "http://${trm_domain}")"
-if [ -n "$(printf "%s" "${response}" | grep "${success}")" ]
-then
-       exit 0
-else
-       exit 2
+raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --silent --show-error --header "Content-Type:application/x-www-form-urlencoded" --data "username=${user}&password=${password}" "http://${trm_domain}")"
+if [ -n "${raw_html##*${success}*}" ]; then
+       exit 1
 fi
index a72e217f73816e63c9563606645779fd4127e848..fa55f7d36ea25ae92b8e172776d07f794a7554f8 100755 (executable)
@@ -1,43 +1,40 @@
 #!/bin/sh
-# captive portal auto-login script for Telekom hotspots in german h+hotels
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# captive portal auto-login script for Telekom hotspots in h+hotels (DE)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2181,3040
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
-       . "/lib/functions.sh"
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+    . "/lib/functions.sh"
 fi
 
 trm_domain="hotspot.t-mobile.net"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
 trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
 trm_fetch="$(command -v curl)"
 
-# initial get request to receive & extract valid security tokens
+# get security tokens
 #
-"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin"
-if [ -r "/tmp/${trm_domain}.cookie" ]
-then
-       ses_id="$(awk '/JSESSIONID/{print $7}' "/tmp/${trm_domain}.cookie")"
-       sec_id="$(awk '/DT_H/{print $7}' "/tmp/${trm_domain}.cookie")"
-       dev_id="$(sha256sum /etc/config/wireless | awk '{printf "%s",substr($1,1,13)}')"
-       rm -f "/tmp/${trm_domain}.cookie"
-else
-       exit 2
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin"
+ses_id="$(awk '/JSESSIONID/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+sec_id="$(awk '/DT_H/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+dev_id="$(sha256sum /etc/config/wireless 2>/dev/null | awk '{printf "%s",substr($1,1,13)}' 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${ses_id}" ] || [ -z "${sec_id}" ] || [ -z "${dev_id}" ]; then
+       exit 1
 fi
 
-# final post request/login with valid session cookie/security token
+# final post request
 #
-if [ -n "${ses_id}" ] && [ -n "${sec_id}" ] && [ -n "${dev_id}" ]
-then
-       "${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/TD/hotspot/H_Hotels/en_GB/index.html" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: JSESSIONID=${ses_id}; DT_DEV_ID=${dev_id}; DT_H=${sec_id}" --data "rememberMe=true" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin"
-else
-       exit 3
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}/TD/hotspot/H_Hotels/en_GB/index.html" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: JSESSIONID=${ses_id}; DT_DEV_ID=${dev_id}; DT_H=${sec_id}" --data "rememberMe=true" --output /dev/null "https://${trm_domain}/wlan/rest/freeLogin"
+if [ "${?}" != "0" ]; then
+       exit 2
 fi
diff --git a/net/travelmate/files/julianahoeve.login b/net/travelmate/files/julianahoeve.login
new file mode 100755 (executable)
index 0000000..f4927c3
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+# captive portal auto-login script for Julianahoeve beach resort (NL)
+# Copyright (c) 2021 Dirk Brenken (dev@brenken.org)
+# This is free software, licensed under the GNU General Public License v3.
+
+# set (s)hellcheck exceptions
+# shellcheck disable=1091,2039,2181,3040
+
+export LC_ALL=C
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+set -o pipefail
+
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+       . "/lib/functions.sh"
+fi
+
+trm_domain="n23.network-auth.com"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
+trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
+trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
+trm_fetch="$(command -v curl)"
+
+# get redirect url
+#
+redirect_url="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --write-out "%{redirect_url}" --silent --show-error --output /dev/null "${trm_captiveurl}")"
+if [ -z "${redirect_url}" ]; then
+       exit 1
+fi
+
+# get session cookie
+#
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "${redirect_url}"
+session_id="$(awk '/p_splash_session/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${session_id}" ]; then
+       exit 2
+fi
+
+# final login request
+#
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "${redirect_url}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: p_splash_session=${session_id};" --output /dev/null "https://${trm_domain}/Camping-Julianah/hi/IHYW9cx/grant"
+if [ "${?}" != "0" ]; then
+       exit 3
+fi
diff --git a/net/travelmate/files/telekom.login b/net/travelmate/files/telekom.login
new file mode 100755 (executable)
index 0000000..060bce7
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+# captive portal auto-login script for telekom hotspots (DE)
+# Copyright (c) 2021 Dirk Brenken (dev@brenken.org)
+# This is free software, licensed under the GNU General Public License v3.
+
+# set (s)hellcheck exceptions
+# shellcheck disable=1091,3040,3043,3057
+
+export LC_ALL=C
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+set -o pipefail
+
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+    . "/lib/functions.sh"
+fi
+
+# url encoding function
+#
+urlencode()
+{
+    local chr str="${1}" len="${#1}" pos=0
+
+    while [ "${pos}" -lt "${len}" ]; do
+        chr="${str:pos:1}"
+        case "${chr}" in
+            [a-zA-Z0-9.~_-])
+                printf "%s" "${chr}"
+                ;;
+            " ")
+                printf "%%20"
+                ;;
+            *)
+                printf "%%%02X" "'${chr}"
+                ;;
+        esac
+        pos=$((pos + 1))
+    done
+}
+
+username="$(urlencode "${1}")"
+password="$(urlencode "${2}")"
+trm_domain="telekom.portal.fon.com"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
+trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
+trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
+trm_fetch="$(command -v curl)"
+
+# get redirect url
+#
+raw_html="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --location --silent --show-error "${trm_captiveurl}")"
+redirect_url="$(printf "%s" "${raw_html}" | awk 'match(tolower($0),/<loginurl>.*<\/loginurl>/){printf "%s",substr($0,RSTART+10,RLENGTH-21)}' 2>/dev/null | awk '{gsub("&amp;","\\&");printf "%s",$0}' 2>/dev/null)"
+if [ -z "${redirect_url}" ]; then
+    exit 1
+fi
+
+# final login request
+#
+raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "https://${trm_domain}" --connect-timeout $((trm_maxwait / 6)) --header "content-type: application/x-www-form-urlencoded" --location --silent --show-error --data "UserName=${username}&Password=${password}&FNAME=0&button=Login&OriginatingServer=http%3A%2F%2F${trm_captiveurl}" "${redirect_url}")"
+login_url="$(printf "%s" "${raw_html}" | awk 'match(tolower($0),/<logoffurl>.*<\/logoffurl>/){printf "%s",substr($0,RSTART+11,RLENGTH-23)}' 2>/dev/null)"
+if [ -z "${login_url}" ]; then
+    exit 2
+fi
index 1346bc6dcc3ad44beec2e213699974d9752d0f9c..2017ba9331b731fd196192d2d79d374c0e6c8c64 100755 (executable)
@@ -3,7 +3,7 @@
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2034,2039,2059,2086,2143,2154,2181,2188
+# shellcheck disable=2034,2086,2154,3043,3060
 
 START=25
 USE_PROCD=1
@@ -17,19 +17,16 @@ trm_pidfile="/var/run/travelmate.pid"
 
 boot()
 {
-       if [ -s "${trm_pidfile}" ]
-       then
-               > "${trm_pidfile}"
+       if [ -s "${trm_pidfile}" ]; then
+               : >"${trm_pidfile}"
        fi
        rc_procd start_service
 }
 
 start_service()
 {
-       if [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ]
-       then
-               if [ "${action}" = "boot" ]
-               then
+       if "${trm_init}" enabled; then
+               if [ "${action}" = "boot" ]; then
                        return 0
                fi
                procd_open_instance "travelmate"
@@ -45,17 +42,14 @@ start_service()
 reload_service()
 {
        local ppid pid timeout
-       
+
        timeout="$(uci_get travelmate global trm_timeout)"
 
-       if [ -s "${trm_pidfile}" ]
-       then
+       if [ -s "${trm_pidfile}" ]; then
                ppid="$(cat "${trm_pidfile}" 2>/dev/null)"
-               if [ -n "${ppid}" ]
-               then
+               if [ -n "${ppid}" ]; then
                        pid="$(pgrep -xnf "sleep ${timeout:-60} 0" -P ${ppid} 2>/dev/null)"
-                       if [ -n "${pid}" ]
-                       then
+                       if [ -n "${pid}" ]; then
                                kill -INT ${pid} 2>/dev/null
                        fi
                fi
@@ -73,13 +67,10 @@ status_service()
 
        rtfile="$(uci_get travelmate global trm_rtfile "/tmp/trm_runtime.json")"
        json_load_file "${rtfile}" >/dev/null 2>&1
-       json_select data >/dev/null 2>&1
-       if [ "${?}" = "0" ]
-       then
+       if json_select data >/dev/null 2>&1; then
                printf "%s\n" "::: travelmate runtime information"
                json_get_keys keylist
-               for key in ${keylist}
-               do
+               for key in ${keylist}; do
                        json_get_var value "${key}"
                        printf "  + %-18s : %s\n" "${key}" "${value}"
                done
@@ -92,21 +83,20 @@ scan()
 {
        local result scan_dev radio="${1:-"radio0"}"
 
-       scan_dev="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -l1 -e "@.${radio}.interfaces[0].ifname")"
-       result="$(iwinfo "${scan_dev:-${radio}}" scan 2>/dev/null | \
+       scan_dev="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e "@.${radio}.interfaces[0].ifname")"
+       result="$(iwinfo "${scan_dev:-${radio}}" scan 2>/dev/null |
                awk 'BEGIN{FS="[[:space:]]"}/Address:/{var1=$NF}/ESSID:/{var2="";
                for(i=12;i<=NF;i++)if(var2==""){var2=$i}else{var2=var2" "$i}}/Channel:/{var3=$NF}/Quality:/{split($NF,var0,"/")}/Encryption:/{var4="";
-               for(j=12;j<=NF;j++)if(var4==""){var4=$j}else{var4=var4" "$j};printf "    %-11i%-10s%-35s%-20s%s\n",(var0[1]*100/var0[2]),var3,var2,var1,var4}' | \
+               for(j=12;j<=NF;j++)if(var4==""){var4=$j}else{var4=var4" "$j};printf "    %-11i%-10s%-35s%-20s%s\n",(var0[1]*100/var0[2]),var3,var2,var1,var4}' |
                sort -rn)"
-       printf "%s\\n" "::: Available nearby uplinks on '${scan_dev:-${radio}}'"
-       printf "%s\\n" ":::"
-       if [ -n "${result}" ]
-       then
-               printf "%-15s%-10s%-35s%-20s%s\\n" "    Strength" "Channel" "ESSID" "BSSID" "Encryption"
-               printf "%s\\n" "    --------------------------------------------------------------------------------------"
-               printf "%s\\n" "${result}"
+       printf '%s\n' "::: Available nearby uplinks on '${scan_dev:-${radio}}'"
+       printf '%s\n' ":::"
+       if [ -n "${result}" ]; then
+               printf '%-15s%-10s%-35s%-20s%s\n' "    Strength" "Channel" "ESSID" "BSSID" "Encryption"
+               printf '%s\n' "    --------------------------------------------------------------------------------------"
+               printf '%s\n' "${result}"
        else
-               printf "%s\\n" "::: No scan results"
+               printf '%s\n' "::: No scan results"
        fi
 }
 
@@ -119,13 +109,10 @@ setup()
        zone="${zone//[+*~%&\$@\"\' ]/}"
        metric="${metric//[^0-9]/}"
 
-       if [ -n "${iface}" ] && [ "${iface}" = "${input}" ]
-       then
+       if [ -n "${iface}" ] && [ "${iface}" = "${input}" ]; then
                printf "%s\n" "The uplink interface '${input}' has been already configured"
-       elif [ -n "${input}" ]
-       then
-               if [ -n "${iface}" ]
-               then
+       elif [ -n "${input}" ]; then
+               if [ -n "${iface}" ]; then
                        uci -q batch <<-EOC
                                del network."${iface}"
                                del network."${iface}6"
@@ -144,12 +131,9 @@ setup()
                        commit network
                EOC
 
-               while [ -n "$(uci -q get firewall.@zone["${cnt}"].name)" ]
-               do
-                       if [ "$(uci -q get firewall.@zone["${cnt}"].name)" = "${zone}" ]
-                       then
-                               if [ -n "${iface}" ]
-                               then
+               while [ -n "$(uci -q get firewall.@zone["${cnt}"].name)" ]; do
+                       if [ "$(uci -q get firewall.@zone["${cnt}"].name)" = "${zone}" ]; then
+                               if [ -n "${iface}" ]; then
                                        uci -q batch <<-EOC
                                                del_list firewall.@zone["${cnt}"].network="${iface}"
                                                del_list firewall.@zone["${cnt}"].network="${iface}6"
@@ -162,19 +146,16 @@ setup()
                                EOC
                                break
                        fi
-                       cnt=$((cnt+1))
+                       cnt=$((cnt + 1))
                done
 
-               if [ -n "${iface}" ]
-               then
+               if [ -n "${iface}" ]; then
                        cnt=0
-                       while [ -n "$(uci -q get wireless.@wifi-iface["${cnt}"].network)" ]
-                       do
-                               if [ "$(uci -q get wireless.@wifi-iface["${cnt}"].network)" = "${iface}" ]
-                               then
+                       while [ -n "$(uci -q get wireless.@wifi-iface["${cnt}"].network)" ]; do
+                               if [ "$(uci -q get wireless.@wifi-iface["${cnt}"].network)" = "${iface}" ]; then
                                        uci -q set wireless.@wifi-iface["${cnt}"].network="${input}"
                                fi
-                               cnt=$((cnt+1))
+                               cnt=$((cnt + 1))
                        done
                        uci -q commit wireless
                fi
@@ -192,8 +173,7 @@ service_triggers()
        delay="$(uci_get travelmate global trm_triggerdelay "2")"
        PROCD_RELOAD_DELAY=$((delay * 1000))
 
-       if [ -n "${iface}" ]
-       then
+       if [ -n "${iface}" ]; then
                procd_add_interface_trigger "interface.*.down" "${iface}" "${trm_init}" reload
        fi
        procd_add_raw_trigger "interface.*.up" "${PROCD_RELOAD_DELAY}" "${trm_init}" start
index 42da3ccf33d75be53c11c0c1f4aa6359f6d87cbf..ec789625aa90d6c11581fe4678ed1789dcd3741e 100755 (executable)
@@ -1,10 +1,10 @@
 #!/bin/sh
 # send mail script for travelmate notifications
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,3040
 
 # Please note: you have to setup the package 'msmtp' before using this script
 
@@ -12,8 +12,9 @@ export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
        . "/lib/functions.sh"
 fi
 
@@ -25,32 +26,21 @@ trm_rtfile="$(uci_get travelmate global trm_rtfile "/tmp/trm_runtime.json")"
 trm_mailpgm="$(command -v msmtp)"
 trm_logger="$(command -v logger)"
 
-f_log()
-{
-       local class="${1}" log_msg="${2}"
-
-       if [ -x "${trm_logger}" ]
-       then
-               "${trm_logger}" -p "${class}" -t "trm-mail [${$}]" "${log_msg}"
-       else
-               printf "%s %s %s\\n" "${class}" "trm-mail [${$}]" "${log_msg}"
-       fi
-}
-
-if [ -z "${trm_mailreceiver}" ]
-then
-       f_log "err" "please set the mail receiver with the 'trm_mailreceiver' option"
+if [ -z "${trm_mailreceiver}" ]; then
+       "${trm_logger}" -p "err" -t "trm-mail [${$}]" "please set the mail receiver with the 'trm_mailreceiver' option" 2>/dev/null
        exit 1
 fi
 
-if [ "${trm_debug}" = "1" ]
-then
+if [ "${trm_debug}" = "1" ]; then
        debug="--debug"
 fi
 
 # info preparation
 #
-sys_info="$(strings /etc/banner 2>/dev/null; ubus call system board | sed -e 's/\"release\": {//' | sed -e 's/^[ \t]*//' | sed -e 's/[{}\",]//g' | sed -e 's/[ ]/  \t/' | sed '/^$/d' 2>/dev/null)"
+sys_info="$(
+       strings /etc/banner 2>/dev/null
+       ubus call system board | sed -e 's/\"release\": {//' | sed -e 's/^[ \t]*//' | sed -e 's/[{}\",]//g' | sed -e 's/[ ]/  \t/' | sed '/^$/d' 2>/dev/null
+)"
 trm_info="$(/etc/init.d/travelmate status 2>/dev/null)"
 sta_info="$(jsonfilter -i "${trm_rtfile}" -l1 -e '@.data.station_id')"
 trm_mailtopic="$(uci_get travelmate global trm_mailtopic "travelmate connection to '${sta_info}'")"
@@ -66,6 +56,4 @@ trm_mailtext="${trm_mailtext}</pre></body></html>"
 # send mail
 #
 printf "%b" "${trm_mailhead}${trm_mailtext}" 2>/dev/null | "${trm_mailpgm}" ${debug} -a "${trm_mailprofile}" "${trm_mailreceiver}" >/dev/null 2>&1
-mail_rc="${?}"
-f_log "info" "mail sent to '${trm_mailreceiver}' with rc '${mail_rc}'"
-exit ${mail_rc}
+"${trm_logger}" -p "info" -t "trm-mail [${$}]" "mail sent to '${trm_mailreceiver}' with rc '${?}'"  2>/dev/null
index 37dacfce33b03ebd8d414694a0c743626db24bf6..cd4313989ee57a99a58adbdb9e16b05a6a230ab7 100755 (executable)
@@ -4,13 +4,13 @@
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2086,3040,3043,3057,3060
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-trm_ver="2.0.3"
+trm_ver="2.0.4"
 trm_enabled=0
 trm_debug=0
 trm_iface=""
@@ -38,8 +38,8 @@ trm_fetch="$(command -v curl)"
 trm_iwinfo="$(command -v iwinfo)"
 trm_logger="$(command -v logger)"
 trm_wpa="$(command -v wpa_supplicant)"
-trm_captiveurl="http://captive.apple.com"
-trm_useragent="Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0"
+trm_captiveurl="http://detectportal.firefox.com"
+trm_useragent="Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0"
 trm_ntpfile="/var/state/travelmate.ntp"
 trm_vpnfile="/var/state/travelmate.vpn"
 trm_mailfile="/var/state/travelmate.mail"
@@ -55,8 +55,7 @@ f_env()
 
        # do nothing on stop
        #
-       if [ "${trm_action}" = "stop" ]
-       then
+       if [ "${trm_action}" = "stop" ]; then
                return
        fi
 
@@ -66,13 +65,12 @@ f_env()
 
        # get system information
        #
-       trm_sysver="$(ubus -S call system board 2>/dev/null | jsonfilter -e '@.model' -e '@.release.description' | \
+       trm_sysver="$(ubus -S call system board 2>/dev/null | jsonfilter -q -e '@.model' -e '@.release.description' |
                awk 'BEGIN{ORS=", "}{print $0}' | awk '{print substr($0,1,length($0)-2)}')"
 
        # check travelmate config
        #
-       if [ ! -r "/etc/config/travelmate" ] || [ -z "$(uci -q show travelmate.global.trm_vpn)" ]
-       then
+       if [ ! -r "/etc/config/travelmate" ] || [ -z "$(uci -q show travelmate.global.trm_vpn)" ]; then
                f_log "err" "invalid travelmate config, please re-install the package via opkg with the '--force-reinstall --force-maintainer' options"
        fi
 
@@ -81,8 +79,7 @@ f_env()
        config_cb()
        {
                local name="${1}" type="${2}"
-               if [ "${name}" = "travelmate" ] && [ "${type}" = "global" ]
-               then
+               if [ "${name}" = "travelmate" ] && [ "${type}" = "global" ]; then
                        option_cb()
                        {
                                local option="${1}" value="${2}"
@@ -99,19 +96,16 @@ f_env()
 
        # check 'enabled' option
        #
-       if [ "${trm_enabled}" != "1" ]
-       then
+       if [ "${trm_enabled}" != "1" ]; then
                f_log "info" "travelmate is currently disabled, please set 'trm_enabled' to '1' to use this service"
                /etc/init.d/travelmate stop
        fi
 
        # check ubus network interface
        #
-       if [ -n "${trm_iface}" ]
-       then
+       if [ -n "${trm_iface}" ]; then
                ubus_check="$(ubus -t "${trm_maxwait}" wait_for network.wireless network.interface."${trm_iface}" 2>&1)"
-               if [ -n "${ubus_check}" ]
-               then
+               if [ -n "${ubus_check}" ]; then
                        f_log "info" "travelmate interface '${trm_iface}' does not appear on ubus, please check your network setup"
                        /etc/init.d/travelmate stop
                fi
@@ -123,22 +117,20 @@ f_env()
        # check wpa capabilities
        #
        wpa_checks="sae owe eap suiteb192"
-       for check in ${wpa_checks}
-       do
-               if [ -x "${trm_wpa}" ]
-               then
-                       result="$("${trm_wpa}" -v${check} >/dev/null 2>&1; printf "%u" "${?}")"
-                       if [ -z "${trm_wpaflags}" ]
-                       then
-                               if [ "${result}" = "0" ]
-                               then
+       for check in ${wpa_checks}; do
+               if [ -x "${trm_wpa}" ]; then
+                       result="$(
+                               "${trm_wpa}" -v${check} >/dev/null 2>&1
+                               printf "%u" "${?}"
+                       )"
+                       if [ -z "${trm_wpaflags}" ]; then
+                               if [ "${result}" = "0" ]; then
                                        trm_wpaflags="${check}: $(f_char 1)"
                                else
                                        trm_wpaflags="${check}: $(f_char 0)"
                                fi
                        else
-                               if [ "${result}" = "0" ]
-                               then
+                               if [ "${result}" = "0" ]; then
                                        trm_wpaflags="$(f_trim "${trm_wpaflags}, ${check}: $(f_char 1)")"
                                else
                                        trm_wpaflags="$(f_trim "${trm_wpaflags}, ${check}: $(f_char 0)")"
@@ -151,8 +143,7 @@ f_env()
        #
        config_load wireless
        config_foreach f_prepdev wifi-device
-       if [ -n "$(uci -q changes "wireless")" ]
-       then
+       if [ -n "$(uci -q changes "wireless")" ]; then
                uci_commit "wireless"
                f_reconf
        fi
@@ -160,10 +151,9 @@ f_env()
        # load json runtime file
        #
        json_load_file "${trm_rtfile}" >/dev/null 2>&1
-       json_select data >/dev/null 2>&1
-       if [ "${?}" != "0" ]
-       then
-               > "${trm_rtfile}"
+
+       if ! json_select data >/dev/null 2>&1; then
+               : >"${trm_rtfile}"
                json_init
                json_add_object "data"
        fi
@@ -187,8 +177,7 @@ f_char()
 {
        local result input="${1}"
 
-       if [ "${input}" = "1" ]
-       then
+       if [ "${input}" = "1" ]; then
                result="āœ”"
        else
                result="āœ˜"
@@ -203,20 +192,16 @@ f_reconf()
        local radio tmp_radio cnt="0"
 
        "${trm_wifi}" reconf
-       for radio in ${trm_radiolist}
-       do
-               while [ "$(ubus -S call network.wireless status | jsonfilter -l1 -e "@.${radio}.up")" != "true" ]
-               do
-                       if [ "${cnt}" -ge "${trm_maxwait}" ]
-                       then
+       for radio in ${trm_radiolist}; do
+               while [ "$(ubus -S call network.wireless status | jsonfilter -q -l1 -e "@.${radio}.up")" != "true" ]; do
+                       if [ "${cnt}" -ge "${trm_maxwait}" ]; then
                                break 2
                        fi
-                       if [ "${radio}" != "${tmp_radio}" ]
-                       then
+                       if [ "${radio}" != "${tmp_radio}" ]; then
                                "${trm_wifi}" up "${radio}"
                                tmp_radio="${radio}"
                        fi
-                       cnt="$((cnt+1))"
+                       cnt="$((cnt + 1))"
                        sleep 1
                done
        done
@@ -229,18 +214,16 @@ f_vpn()
 {
        local IFS rc action="${1}"
 
-       if [ "${trm_vpn}" = "1" ] && [ -x "${trm_vpnpgm}" ]
-       then
-               if [ "${action}" = "disable" ] || { [ "${action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; }
-               then
+       if [ "${trm_vpn}" = "1" ] && [ -x "${trm_vpnpgm}" ]; then
+               if [ "${action}" = "disable" ] || {
+                       [ "${action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]
+               }; then
                        "${trm_vpnpgm}" "${action}" >/dev/null 2>&1
                        rc="${?}"
                fi
-               if [ "${action}" = "enable" ] && [ "${rc}" = "0" ]
-               then
-                       > "${trm_vpnfile}"
-               elif [ "${action}" = "disable" ] && [ -f "${trm_vpnfile}" ]
-               then
+               if [ "${action}" = "enable" ] && [ "${rc}" = "0" ]; then
+                       : >"${trm_vpnfile}"
+               elif [ "${action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; then
                        rm -f "${trm_vpnfile}"
                fi
        fi
@@ -253,16 +236,14 @@ f_mac()
 {
        local result ifname action="${1}" section="${2}"
 
-       if [ "${trm_randomize}" = "1" ] && [ "${action}" = "set" ]
-       then
-               result="$(hexdump -n6 -ve '/1 "%.02X "' /dev/random 2>/dev/null | \
+       if [ "${trm_randomize}" = "1" ] && [ "${action}" = "set" ]; then
+               result="$(hexdump -n6 -ve '/1 "%.02X "' /dev/random 2>/dev/null |
                        awk -v local="2,6,A,E" -v seed="$(date +%s)" 'BEGIN{srand(seed)}NR==1{split(local,b,",");seed=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s",substr($1,0,1),b[seed],$2,$3,$4,$5,$6}')"
                uci_set "wireless" "${section}" "macaddr" "${result}"
        else
                result="$(uci_get "wireless" "${section}" "macaddr")"
-               if [ -z "${result}" ]
-               then
-                       ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
+               if [ -z "${result}" ]; then
+                       ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
                        result="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk '/Access Point:/{printf "%s",$3}')"
                fi
        fi
@@ -276,73 +257,65 @@ f_contrack()
 {
        local uplink_config radio_config essid_config bssid_config expiry action="${1}" radio="${2}" essid="${3}" bssid="${4}" cnt=0
 
-       while [ "$(uci_get "travelmate" "@uplink[$cnt]" >/dev/null 2>&1; echo $?)" = "0" ]
-       do
+       while [ "$(
+               uci_get "travelmate" "@uplink[$cnt]" >/dev/null 2>&1
+               echo $?
+       )" = "0" ]; do
                radio_config="$(uci_get "travelmate" "@uplink[$cnt]" "device")"
                essid_config="$(uci_get "travelmate" "@uplink[$cnt]" "ssid")"
                bssid_config="$(uci_get "travelmate" "@uplink[$cnt]" "bssid")"
-               if [ "${radio_config}" = "${radio}" ] && [ "${essid_config}" = "${essid}" ] && [ "${bssid_config}" = "${bssid}" ]
-               then
+               if [ "${radio_config}" = "${radio}" ] && [ "${essid_config}" = "${essid}" ] && [ "${bssid_config}" = "${bssid}" ]; then
                        uplink_config="@uplink[$cnt]"
                fi
-               cnt="$((cnt+1))"
+               cnt="$((cnt + 1))"
        done
-       if [ -n "${uplink_config}" ]
-       then
+       if [ -n "${uplink_config}" ]; then
                case "${action}" in
                        "start")
                                uci_remove "travelmate" "${uplink_config}" "con_start" 2>/dev/null
                                uci_remove "travelmate" "${uplink_config}" "con_end" 2>/dev/null
-                               if [ -f "${trm_ntpfile}" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ]; then
                                        uci_set "travelmate" "${uplink_config}" "con_start" "$(date "+%Y.%m.%d-%H:%M:%S")"
                                fi
-                       ;;
+                               ;;
                        "refresh")
-                               if [ -f "${trm_ntpfile}" ] && [ -z "$(uci_get "travelmate" "${uplink_config}" "con_start")" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ] && [ -z "$(uci_get "travelmate" "${uplink_config}" "con_start")" ]; then
                                        uci_set "travelmate" "${uplink_config}" "con_start" "$(date "+%Y.%m.%d-%H:%M:%S")"
                                fi
-                       ;;
+                               ;;
                        "end")
-                               if [ -f "${trm_ntpfile}" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ]; then
                                        uci_set "travelmate" "${uplink_config}" "con_end" "$(date "+%Y.%m.%d-%H:%M:%S")"
                                fi
-                       ;;
+                               ;;
                        "start_expiry")
-                               if [ -f "${trm_ntpfile}" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ]; then
                                        expiry="$(uci_get "travelmate" "${uplink_config}" "con_start_expiry")"
                                        uci_set "travelmate" "${uplink_config}" "enabled" "0"
                                        uci_set "travelmate" "${uplink_config}" "con_end" "$(date "+%Y.%m.%d-%H:%M:%S")"
                                        f_log "info" "uplink '${radio}/${essid}/${bssid:-"-"}' expired after ${expiry} minutes"
                                fi
-                       ;;
+                               ;;
                        "end_expiry")
-                               if [ -f "${trm_ntpfile}" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ]; then
                                        expiry="$(uci_get "travelmate" "${uplink_config}" "con_end_expiry")"
                                        uci_set "travelmate" "${uplink_config}" "enabled" "1"
                                        uci_remove "travelmate" "${uplink_config}" "con_start" 2>/dev/null
                                        uci_remove "travelmate" "${uplink_config}" "con_end" 2>/dev/null
                                        f_log "info" "uplink '${radio}/${essid}/${bssid:-"-"}' re-enabled after ${expiry} minutes"
                                fi
-                       ;;
+                               ;;
                        "disabled")
                                uci_set "travelmate" "${uplink_config}" "enabled" "0"
-                               if [ -f "${trm_ntpfile}" ]
-                               then
+                               if [ -f "${trm_ntpfile}" ]; then
                                        uci_set "travelmate" "${uplink_config}" "con_end" "$(date "+%Y.%m.%d-%H:%M:%S")"
                                fi
-                       ;;
+                               ;;
                esac
-               if [ -n "$(uci -q changes "travelmate")" ]
-               then
+               if [ -n "$(uci -q changes "travelmate")" ]; then
                        uci_commit "travelmate"
-                       if [ ! -f "${trm_refreshfile}" ]
-                       then
-                               printf "%s" "cfg_reload" > "${trm_refreshfile}"
+                       if [ ! -f "${trm_refreshfile}" ]; then
+                               printf "%s" "cfg_reload" >"${trm_refreshfile}"
                        fi
                fi
        fi
@@ -354,18 +327,19 @@ f_uplink()
 {
        local IFS result t_radio t_essid t_bssid t_option="${1}" w_radio="${2}" w_essid="${3}" w_bssid="${4}" cnt=0
 
-       while [ "$(uci_get "travelmate" "@uplink[$cnt]" >/dev/null 2>&1; echo $?)" = "0" ]
-       do
+       while [ "$(
+               uci_get "travelmate" "@uplink[$cnt]" >/dev/null 2>&1
+               echo $?
+       )" = "0" ]; do
                t_radio="$(uci_get "travelmate" "@uplink[$cnt]" "device")"
                t_essid="$(uci_get "travelmate" "@uplink[$cnt]" "ssid")"
                t_bssid="$(uci_get "travelmate" "@uplink[$cnt]" "bssid")"
-               if [ -n "${w_radio}" ] && [ -n "${w_essid}" ] && \
-                       [ "${t_radio}" = "${w_radio}" ] && [ "${t_essid}" = "${w_essid}" ] && [ "${t_bssid}" = "${w_bssid}" ]
-               then
+               if [ -n "${w_radio}" ] && [ -n "${w_essid}" ] &&
+                       [ "${t_radio}" = "${w_radio}" ] && [ "${t_essid}" = "${w_essid}" ] && [ "${t_bssid}" = "${w_bssid}" ]; then
                        result="$(uci_get "travelmate" "@uplink[$cnt]" "${t_option}")"
                        break
                fi
-               cnt="$((cnt+1))"
+               cnt="$((cnt + 1))"
        done
        printf "%s" "${result}"
        f_log "debug" "f_uplink  ::: option: ${t_option}, result: ${result}"
@@ -378,17 +352,14 @@ f_prepdev()
        local IFS disabled radio="${1}"
 
        disabled="$(uci_get "wireless" "${radio}" "disabled")"
-       if [ "${disabled}" = "1" ]
-       then
+       if [ "${disabled}" = "1" ]; then
                uci_set wireless "${radio}" disabled 0
        fi
 
-       if [ -z "${trm_radio}" ] && [ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo "${radio}")" ]
-       then
+       if [ -z "${trm_radio}" ] && ! printf "%s" "${trm_radiolist}" | grep -q "${radio}"; then
                trm_radiolist="$(f_trim "${trm_radiolist} ${radio}")"
-       elif [ -n "${trm_radio}" ] && [ -z "${trm_radiolist}" ]
-       then
-               trm_radiolist="$(f_trim "$(printf "%s" "${trm_radio}" | \
+       elif [ -n "${trm_radio}" ] && [ -z "${trm_radiolist}" ]; then
+               trm_radiolist="$(f_trim "$(printf "%s" "${trm_radio}" |
                        awk '{while(match(tolower($0),/[a-z0-9_]+/)){ORS=" ";print substr(tolower($0),RSTART,RLENGTH);$0=substr($0,RSTART+RLENGTH)}}')")"
        fi
        f_log "debug" "f_prepdev ::: trm_radio: ${trm_radio:-"-"}, radio: ${radio}, radio_list: ${trm_radiolist:-"-"}, disabled: ${disabled:-"-"}"
@@ -403,26 +374,21 @@ f_addif()
        config_cb()
        {
                local type="${1}" name="${2}"
-               if [ "${type}" = "wifi-iface" ]
-               then
-                       if [ "$(uci -q get "wireless.${name}.ssid")" = "${essid}" ]
-                       then
+               if [ "${type}" = "wifi-iface" ]; then
+                       if [ "$(uci -q get "wireless.${name}.ssid")" = "${essid}" ]; then
                                offset=0
-                       elif [ "${offset}" != "0" ]
-                       then
-                               offset="$((offset+1))"
+                       elif [ "${offset}" != "0" ]; then
+                               offset="$((offset + 1))"
                        fi
                fi
                return "${offset}"
        }
        config_load wireless
 
-       if [ "${offset}" != "0" ]
-       then
+       if [ "${offset}" != "0" ]; then
                uci_cfg="trm_uplink${offset}"
-               while [ -n "$(uci -q get "wireless.${uci_cfg}")" ]
-               do
-                       offset="$((offset+1))"
+               while [ -n "$(uci -q get "wireless.${uci_cfg}")" ]; do
+                       offset="$((offset + 1))"
                        uci_cfg="trm_uplink${offset}"
                done
                uci -q batch <<-EOC
@@ -442,14 +408,12 @@ f_addif()
                        set travelmate."${uci_cfg}".con_end_expiry="0"
                        set travelmate."${uci_cfg}".enabled="1"
                EOC
-               if [ -n "$(uci -q changes "travelmate")" ] || [ -n "$(uci -q changes "wireless")" ]
-               then
+               if [ -n "$(uci -q changes "travelmate")" ] || [ -n "$(uci -q changes "wireless")" ]; then
                        uci_commit "travelmate"
                        uci_commit "wireless"
                        f_reconf
-                       if [ ! -f "${trm_refreshfile}" ]
-                       then
-                               printf "%s" "ui_reload" > "${trm_refreshfile}"
+                       if [ ! -f "${trm_refreshfile}" ]; then
+                               printf "%s" "ui_reload" >"${trm_refreshfile}"
                        fi
                        f_log "info" "open uplink '${radio}/${essid}' added to wireless config"
                fi
@@ -474,45 +438,42 @@ f_prepif()
        con_start_expiry="$(f_uplink "con_start_expiry" "${radio}" "${essid}" "${bssid}")"
        con_end_expiry="$(f_uplink "con_end_expiry" "${radio}" "${essid}" "${bssid}")"
 
-       if [ "${status}" = "0" ] && [ -n "${con_end}" ] && [ -n "${con_end_expiry}" ] && [ "${con_end_expiry}" != "0" ]
-       then
+       if [ "${status}" = "0" ] && [ -n "${con_end}" ] && [ -n "${con_end_expiry}" ] && [ "${con_end_expiry}" != "0" ]; then
                d1="$(date -d "${con_end}" "+%s")"
                d2="$(date "+%s")"
-               d3="$(((d2-d1)/60))"
-               if [ "${d3}" -ge "${con_end_expiry}" ]
-               then
+               d3="$(((d2 - d1) / 60))"
+               if [ "${d3}" -ge "${con_end_expiry}" ]; then
                        status="1"
                        f_contrack "end_expiry" "${radio}" "${essid}" "${bssid}"
                fi
-       elif [ "${status}" = "1" ] && [ -n "${con_start}" ] && [ -n "${con_start_expiry}" ] && [ "${con_start_expiry}" != "0" ]
-       then
+       elif [ "${status}" = "1" ] && [ -n "${con_start}" ] && [ -n "${con_start_expiry}" ] && [ "${con_start_expiry}" != "0" ]; then
                d1="$(date -d "${con_start}" "+%s")"
                d2="$(date "+%s")"
-               d3="$((d1+(con_start_expiry*60)))"
-               if [ "${d2}" -gt "${d3}" ]
-               then
+               d3="$((d1 + (con_start_expiry * 60)))"
+               if [ "${d2}" -gt "${d3}" ]; then
                        status="0"
                        f_contrack "start_expiry" "${radio}" "${essid}" "${bssid}"
                fi
        fi
 
-       if [ "${mode}" = "sta" ]
-       then
-               if [ "${status}" = "0" ] || \
-                       { { [ -z "${disabled}" ] || [ "${disabled}" = "0" ]; } && { [ "${proactive}" = "0" ] || [ "${trm_ifstatus}" != "true" ]; } }
-               then
+       if [ "${mode}" = "sta" ]; then
+               if [ "${status}" = "0" ] ||
+                       {
+                               {
+                                       [ -z "${disabled}" ] || [ "${disabled}" = "0" ]
+                               } && {
+                                       [ "${proactive}" = "0" ] || [ "${trm_ifstatus}" != "true" ]
+                               }
+                       }; then
                        uci_set "wireless" "${section}" "disabled" "1"
-               elif [ "${disabled}" = "0" ] && [ "${trm_ifstatus}" = "true" ] && [ "${proactive}" = "1" ]
-               then
-                       if [ -z "${trm_activesta}" ]
-                       then
+               elif [ "${disabled}" = "0" ] && [ "${trm_ifstatus}" = "true" ] && [ "${proactive}" = "1" ]; then
+                       if [ -z "${trm_activesta}" ]; then
                                trm_activesta="${section}"
                        else
                                uci_set "wireless" "${section}" "disabled" "1"
                        fi
                fi
-               if [ "${status}" = "1" ]
-               then
+               if [ "${status}" = "1" ]; then
                        trm_stalist="$(f_trim "${trm_stalist} ${section}-${radio}")"
                fi
        fi
@@ -523,41 +484,39 @@ f_prepif()
 #
 f_net()
 {
-       local IFS err err_rc err_domain json_raw json_cp json_rc cp_domain result="net nok"
+       local IFS err err_rc err_domain raw html_raw html_cp json_raw json_cp json_rc result="net nok"
 
-       json_raw="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --write-out "%{json}" --silent --show-error --connect-timeout $((trm_maxwait/10)) "${trm_captiveurl}" 2>/tmp/trm_fetch.err)"
-       json_raw="${json_raw#*\{}"
-       if [ -s "/tmp/trm_fetch.err" ]
-       then
+       raw="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --header "Cache-Control: no-cache, no-store, must-revalidate" --header "Pragma: no-cache" --header "Expires: 0" --write-out "%{json}" --silent --show-error --connect-timeout $((trm_maxwait / 10)) "${trm_captiveurl}" 2>/tmp/trm_fetch.err)"
+       json_raw="${raw#*\{}"
+       html_raw="${raw%%\{*}"
+       if [ -s "/tmp/trm_fetch.err" ]; then
                err="$(awk 'BEGIN{FS="[()'\'' ]"}{printf "%s %s",$3,$(NF-1)}' "/tmp/trm_fetch.err")"
                err_rc="${err% *}"
                err_domain="${err#* }"
-               if [ "${err_rc}" = "6" ]
-               then
-                       if [ -n "${err_domain}" ] && [ "${err_domain}" != "timed" ] && [ "${err_domain}" != "${trm_captiveurl#http*://*}" ]
-                       then
+               if [ "${err_rc}" = "6" ]; then
+                       if [ -n "${err_domain}" ] && [ "${err_domain}" != "timed" ] && [ "${err_domain}" != "${trm_captiveurl#http*://*}" ]; then
                                result="net cp '${err_domain}'"
                        fi
                fi
-       elif [ -n "${json_raw}" ]
-       then
-               json_cp="$(printf "%s" "{${json_raw}" | jsonfilter -l1 -e '@.redirect_url' 2>/dev/null)"
-               json_rc="$(printf "%s" "{${json_raw}" | jsonfilter -l1 -e '@.response_code' 2>/dev/null)"
-               if [ -n "${json_cp}" ]
-               then
-                       cp_domain="${json_cp#http*://*}"
-                       cp_domain="${cp_domain%%/*}"
-                       result="net cp '${cp_domain}'"
+       elif [ -n "${json_raw}" ]; then
+               json_cp="$(printf "%s" "{${json_raw}" | jsonfilter -q -l1 -e '@.redirect_url' | awk 'BEGIN{FS="/"}{printf "%s",$3}')"
+               json_rc="$(printf "%s" "{${json_raw}" | jsonfilter -q -l1 -e '@.response_code')"
+               if [ -n "${json_cp}" ]; then
+                       result="net cp '${json_cp}'"
                else
-                       if [ "${json_rc}" = "200" ] || [ "${json_rc}" = "204" ]
-                       then
-                               result="net ok"
+                       if [ "${json_rc}" = "200" ] || [ "${json_rc}" = "204" ]; then
+                               html_cp="$(printf "%s" "${html_raw}" | awk 'match(tolower($0),/^.*<meta[ \t]+http-equiv=["]*refresh.*[ \t;]url=/){print substr(tolower($0),RLENGTH+1)}' | awk 'BEGIN{FS="[:/]"}{printf "%s",$4;exit}')"
+                               if [ -n "${html_cp}" ]; then
+                                       result="net cp '${html_cp}'"
+                               else
+                                       result="net ok"
+                               fi
                        fi
                fi
        fi
        rm -f "/tmp/trm_fetch.err"
        printf "%s" "${result}"
-       f_log "debug" "f_net     ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait/6)), url: ${trm_captiveurl}, user_agent: ${trm_useragent}, result: ${result}, error: ${err:-"-"}"
+       f_log "debug" "f_net     ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait / 6)), url: ${trm_captiveurl}, user_agent: ${trm_useragent}, cp (json/html): ${json_cp:-"-"}/${html_cp:-"-"}, result: ${result}, error: ${err:-"-"}"
 }
 
 # check interface status
@@ -566,8 +525,7 @@ f_check()
 {
        local IFS ifname radio dev_status result login_script login_script_args cp_domain wait_time="1" enabled="1" mode="${1}" status="${2}" sta_radio="${3}" sta_essid="${4}" sta_bssid="${5}"
 
-       if [ "${mode}" = "initial" ] || [ "${mode}" = "dev" ]
-       then
+       if [ "${mode}" = "initial" ] || [ "${mode}" = "dev" ]; then
                json_get_var station_id "station_id"
                sta_radio="${station_id%%/*}"
                sta_essid="${station_id%/*}"
@@ -575,77 +533,68 @@ f_check()
                sta_bssid="${station_id##*/}"
                sta_bssid="${sta_bssid//-/}"
        fi
-       if [ "${mode}" != "rev" ] && [ -n "${sta_radio}" ] && [ "${sta_radio}" != "-" ] && [ -n "${sta_essid}" ] && [ "${sta_essid}" != "-" ]
-       then
+       if [ "${mode}" != "rev" ] && [ -n "${sta_radio}" ] && [ "${sta_radio}" != "-" ] && [ -n "${sta_essid}" ] && [ "${sta_essid}" != "-" ]; then
                enabled="$(f_uplink "enabled" "${sta_radio}" "${sta_essid}" "${sta_bssid}")"
        fi
-       if { [ "${mode}" != "initial" ] && [ "${mode}" != "dev" ] && [ "${status}" = "false" ]; } || \
-               { [ "${mode}" = "dev" ] && { [ "${status}" = "false" ] || { [ "${trm_ifstatus}" != "${status}" ] && [ "${enabled}" = "0" ]; }; }; }
-       then
+       if {
+               [ "${mode}" != "initial" ] && [ "${mode}" != "dev" ] && [ "${status}" = "false" ]
+       } ||
+               {
+                       [ "${mode}" = "dev" ] && {
+                               [ "${status}" = "false" ] || {
+                                       [ "${trm_ifstatus}" != "${status}" ] && [ "${enabled}" = "0" ]
+                               }
+                       }
+               }; then
                f_reconf
        fi
-       while [ "${wait_time}" -le "${trm_maxwait}" ]
-       do
+       while [ "${wait_time}" -le "${trm_maxwait}" ]; do
                dev_status="$(ubus -S call network.wireless status 2>/dev/null)"
-               if [ -n "${dev_status}" ]
-               then
-                       if [ "${mode}" = "dev" ]
-                       then
-                               if [ "${trm_ifstatus}" != "${status}" ]
-                               then
+               if [ -n "${dev_status}" ]; then
+                       if [ "${mode}" = "dev" ]; then
+                               if [ "${trm_ifstatus}" != "${status}" ]; then
                                        trm_ifstatus="${status}"
                                        f_jsnup
                                fi
-                               if [ "${status}" = "false" ]
-                               then
-                                       sleep "$((trm_maxwait/5))"
+                               if [ "${status}" = "false" ]; then
+                                       sleep "$((trm_maxwait / 5))"
                                fi
                                break
-                       elif [ "${mode}" = "rev" ]
-                       then
+                       elif [ "${mode}" = "rev" ]; then
                                break
                        else
-                               ifname="$(printf "%s" "${dev_status}" | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
-                               if [ -n "${ifname}" ] && [ "${enabled}" = "1" ]
-                               then
+                               ifname="$(printf "%s" "${dev_status}" | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
+                               if [ -n "${ifname}" ] && [ "${enabled}" = "1" ]; then
                                        result="$(f_net)"
                                        trm_ifquality="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk -F '[ ]' '/Link Quality:/{split($NF,var0,"/");printf "%i\n",(var0[1]*100/var0[2])}')"
-                                       if [ "${trm_ifquality}" -ge "${trm_minquality}" ]
-                                       then
-                                               trm_ifstatus="$(ubus -S call network.interface dump 2>/dev/null | jsonfilter -l1 -e "@.interface[@.device=\"${ifname}\"].up")"
-                                               if [ "${trm_ifstatus}" = "true" ]
-                                               then
-                                                       if [ "${trm_captive}" = "1" ]
-                                                       then
+                                       if [ "${trm_ifquality}" -ge "${trm_minquality}" ]; then
+                                               trm_ifstatus="$(ubus -S call network.interface dump 2>/dev/null | jsonfilter -q -l1 -e "@.interface[@.device=\"${ifname}\"].up")"
+                                               if [ "${trm_ifstatus}" = "true" ]; then
+                                                       if [ "${trm_captive}" = "1" ]; then
                                                                cp_domain="$(printf "%s" "${result}" | awk -F '['\''| ]' '/^net cp/{printf "%s",$4}')"
-                                                               if [ -x "/etc/init.d/dnsmasq" ] && [ -f "/etc/config/dhcp" ] && \
-                                                                       [ -n "${cp_domain}" ] && [ -z "$(uci_get "dhcp" "@dnsmasq[0]" "rebind_domain" | grep -Fo "${cp_domain}")" ]
-                                                               then
+                                                               if [ -x "/etc/init.d/dnsmasq" ] && [ -f "/etc/config/dhcp" ] &&
+                                                                       [ -n "${cp_domain}" ] && ! uci_get "dhcp" "@dnsmasq[0]" "rebind_domain" | grep -q "${cp_domain}"; then
                                                                        uci_add_list "dhcp" "@dnsmasq[0]" "rebind_domain" "${cp_domain}"
                                                                        uci_commit "dhcp"
                                                                        /etc/init.d/dnsmasq reload
                                                                        f_log "info" "captive portal domain '${cp_domain}' added to to dhcp rebind whitelist"
                                                                fi
-                                                               if [ -n "${cp_domain}" ] && [ "${trm_captive}" = "1" ]
-                                                               then
+                                                               if [ -n "${cp_domain}" ] && [ "${trm_captive}" = "1" ]; then
                                                                        trm_connection="${result:-"-"}/${trm_ifquality}"
                                                                        f_jsnup
                                                                        login_script="$(f_uplink "script" "${sta_radio}" "${sta_essid}" "${sta_bssid}")"
-                                                                       if [ -x "${login_script}" ]
-                                                                       then
+                                                                       if [ -x "${login_script}" ]; then
                                                                                login_script_args="$(f_uplink "script_args" "${sta_radio}" "${sta_essid}" "${sta_bssid}")"
                                                                                "${login_script}" ${login_script_args} >/dev/null 2>&1
                                                                                rc="${?}"
-                                                                               f_log "info" "captive portal login '${login_script:0:40} ${login_script_args:0:20}' for '${cp_domain}' has been executed with rc '${rc}'"
-                                                                               if [ "${rc}" = "0" ]
-                                                                               then
+                                                                               f_log "info" "captive portal login for '${cp_domain}' has been executed with rc '${rc}'"
+                                                                               if [ "${rc}" = "0" ]; then
                                                                                        result="$(f_net)"
                                                                                fi
                                                                        fi
                                                                fi
                                                        fi
-                                                       if [ "${trm_netcheck}" = "1" ] && [ "${result}" = "net nok" ]
-                                                       then
+                                                       if [ "${trm_netcheck}" = "1" ] && [ "${result}" = "net nok" ]; then
                                                                f_log "info" "uplink has no internet (new connection)"
                                                                f_vpn "disable"
                                                                trm_ifstatus="${status}"
@@ -656,17 +605,14 @@ f_check()
                                                        f_jsnup
                                                        break
                                                fi
-                                       elif [ -n "${trm_connection}" ]
-                                       then
-                                               if [ "${trm_ifquality}" -lt "${trm_minquality}" ]
-                                               then
+                                       elif [ -n "${trm_connection}" ]; then
+                                               if [ "${trm_ifquality}" -lt "${trm_minquality}" ]; then
                                                        f_log "info" "uplink is out of range (${trm_ifquality}/${trm_minquality})"
                                                        f_vpn "disable"
                                                        unset trm_connection
                                                        trm_ifstatus="${status}"
                                                        f_contrack "end" "${sta_radio}" "${sta_essid}" "${sta_bssid}"
-                                               elif [ "${trm_netcheck}" = "1" ] && [ "${result}" = "net nok" ]
-                                               then
+                                               elif [ "${trm_netcheck}" = "1" ] && [ "${result}" = "net nok" ]; then
                                                        f_log "info" "uplink has no internet (existing connection)"
                                                        f_vpn "disable"
                                                        unset trm_connection
@@ -674,34 +620,30 @@ f_check()
                                                fi
                                                f_jsnup
                                                break
-                                       elif [ "${mode}" = "initial" ]
-                                       then
+                                       elif [ "${mode}" = "initial" ]; then
                                                trm_ifstatus="${status}"
                                                f_jsnup
                                                break
                                        fi
-                               elif [ -n "${trm_connection}" ]
-                               then
+                               elif [ -n "${trm_connection}" ]; then
                                        f_vpn "disable"
                                        unset trm_connection
                                        trm_ifstatus="${status}"
                                        f_jsnup
                                        break
-                               elif [ "${mode}" = "initial" ]
-                               then
+                               elif [ "${mode}" = "initial" ]; then
                                        trm_ifstatus="${status}"
                                        f_jsnup
                                        break
                                fi
                        fi
                fi
-               if [ "${mode}" = "initial" ]
-               then
+               if [ "${mode}" = "initial" ]; then
                        trm_ifstatus="${status}"
                        f_jsnup
                        break
                fi
-               wait_time="$((wait_time+1))"
+               wait_time="$((wait_time + 1))"
                sleep 1
        done
        f_log "debug" "f_check   ::: mode: ${mode}, name: ${ifname:-"-"}, status: ${trm_ifstatus}, enabled: ${enabled}, connection: ${trm_connection:-"-"}, wait: ${wait_time}, max_wait: ${trm_maxwait}, min_quality: ${trm_minquality}, captive: ${trm_captive}, netcheck: ${trm_netcheck}"
@@ -713,15 +655,12 @@ f_jsnup()
 {
        local IFS section last_date last_station sta_iface sta_radio sta_essid sta_bssid sta_mac dev_status last_status status="${trm_ifstatus}" ntp_done="0" vpn_done="0" mail_done="0"
 
-       if [ "${status}" = "true" ]
-       then
+       if [ "${status}" = "true" ]; then
                status="connected (${trm_connection:-"-"})"
                dev_status="$(ubus -S call network.wireless status 2>/dev/null)"
-               if [ -n "${dev_status}" ]
-               then
-                       section="$(printf "%s" "${dev_status}" | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].section')"
-                       if [ -n "${section}" ]
-                       then
+               if [ -n "${dev_status}" ]; then
+                       section="$(printf "%s" "${dev_status}" | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].section')"
+                       if [ -n "${section}" ]; then
                                sta_iface="$(uci_get "wireless" "${section}" "network")"
                                sta_radio="$(uci_get "wireless" "${section}" "device")"
                                sta_essid="$(uci_get "wireless" "${section}" "ssid")"
@@ -733,17 +672,18 @@ f_jsnup()
                json_get_var last_station "station_id"
                json_get_var last_status "travelmate_status"
 
-               if { [ -f "${trm_ntpfile}" ] && [ ! -s "${trm_ntpfile}" ]; } || [ "${last_status}" = "running (not connected)" ] || \
-                       { [ -n "${last_station}" ] && [ "${last_station}" != "${sta_radio:-"-"}/${sta_essid:-"-"}/${sta_bssid:-"-"}" ]; }
-               then
+               if {
+                       [ -f "${trm_ntpfile}" ] && [ ! -s "${trm_ntpfile}" ]
+               } || [ "${last_status}" = "running (not connected)" ] ||
+                       {
+                               [ -n "${last_station}" ] && [ "${last_station}" != "${sta_radio:-"-"}/${sta_essid:-"-"}/${sta_bssid:-"-"}" ]
+                       }; then
                        last_date="$(date "+%Y.%m.%d-%H:%M:%S")"
-                       if [ -f "${trm_ntpfile}" ] && [ ! -s "${trm_ntpfile}" ]
-                       then
-                               printf "%s" "${last_date}" > "${trm_ntpfile}"
+                       if [ -f "${trm_ntpfile}" ] && [ ! -s "${trm_ntpfile}" ]; then
+                               printf "%s" "${last_date}" >"${trm_ntpfile}"
                        fi
                fi
-       elif [ "${status}" = "error" ]
-       then
+       elif [ "${status}" = "error" ]; then
                unset trm_connection
                status="program error"
        else
@@ -751,20 +691,16 @@ f_jsnup()
                status="running (not connected)"
        fi
 
-       if [ -z "${last_date}" ]
-       then
+       if [ -z "${last_date}" ]; then
                last_date="$(date "+%Y.%m.%d-%H:%M:%S")"
        fi
-       if [ -s "${trm_ntpfile}" ]
-       then
+       if [ -s "${trm_ntpfile}" ]; then
                ntp_done="1"
        fi
-       if [ "${trm_vpn}" = "1" ] && [ -f "${trm_vpnfile}" ]
-       then
+       if [ "${trm_vpn}" = "1" ] && [ -f "${trm_vpnfile}" ]; then
                vpn_done="1"
        fi
-       if [ "${trm_mail}" = "1" ] && [ -f "${trm_mailfile}" ]
-       then
+       if [ "${trm_mail}" = "1" ] && [ -f "${trm_mailfile}" ]; then
                mail_done="1"
        fi
        json_add_string "travelmate_status" "${status}"
@@ -777,16 +713,13 @@ f_jsnup()
        json_add_string "ext_hooks" "ntp: $(f_char ${ntp_done}), vpn: $(f_char ${vpn_done}), mail: $(f_char ${mail_done})"
        json_add_string "last_run" "${last_date}"
        json_add_string "system" "${trm_sysver}"
-       json_dump > "${trm_rtfile}"
+       json_dump >"${trm_rtfile}"
 
-       if [ "${status%% (net ok/*}" = "connected" ]
-       then
+       if [ "${status%% (net ok/*}" = "connected" ]; then
                f_vpn "enable"
-               if [ "${trm_mail}" = "1" ] && [ -x "${trm_mailpgm}" ] && [ "${ntp_done}" = "1" ] && [ "${mail_done}" = "0" ]
-               then
-                       if [ "${trm_vpn}" = "0" ] || [ "${vpn_done}" = "1" ]
-                       then
-                               > "${trm_mailfile}"
+               if [ "${trm_mail}" = "1" ] && [ -x "${trm_mailpgm}" ] && [ "${ntp_done}" = "1" ] && [ "${mail_done}" = "0" ]; then
+                       if [ "${trm_vpn}" = "0" ] || [ "${vpn_done}" = "1" ]; then
+                               : >"${trm_mailfile}"
                                "${trm_mailpgm}" >/dev/null 2>&1
                        fi
                fi
@@ -802,19 +735,18 @@ f_log()
 {
        local IFS class="${1}" log_msg="${2}"
 
-       if [ -n "${log_msg}" ] && { [ "${class}" != "debug" ] || [ "${trm_debug}" = "1" ]; }
-       then
-               if [ -x "${trm_logger}" ]
-               then
+       if [ -n "${log_msg}" ] && {
+               [ "${class}" != "debug" ] || [ "${trm_debug}" = "1" ]
+       }; then
+               if [ -x "${trm_logger}" ]; then
                        "${trm_logger}" -p "${class}" -t "trm-${trm_ver}[${$}]" "${log_msg}"
                else
-                       printf "%s %s %s\\n" "${class}" "trm-${trm_ver}[${$}]" "${log_msg}"
+                       printf '%s %s %s\n' "${class}" "trm-${trm_ver}[${$}]" "${log_msg}"
                fi
-               if [ "${class}" = "err" ]
-               then
+               if [ "${class}" = "err" ]; then
                        trm_ifstatus="error"
                        f_jsnup
-                       "${trm_pidfile}"
+                       : >"${trm_pidfile}"
                        exit 1
                fi
        fi
@@ -829,12 +761,10 @@ f_main()
 
        f_check "initial" "false"
        f_log "debug" "f_main    ::: status: ${trm_ifstatus}, proactive: ${trm_proactive}"
-       if [ "${trm_ifstatus}" != "true" ] || [ "${trm_proactive}" = "1" ]
-       then
+       if [ "${trm_ifstatus}" != "true" ] || [ "${trm_proactive}" = "1" ]; then
                config_load wireless
                config_foreach f_prepif wifi-iface ${trm_proactive}
-               if [ "${trm_ifstatus}" = "true" ] && [ -n "${trm_activesta}" ] && [ "${trm_proactive}" = "1" ]
-               then
+               if [ "${trm_ifstatus}" = "true" ] && [ -n "${trm_activesta}" ] && [ "${trm_proactive}" = "1" ]; then
                        json_get_var station_id "station_id"
                        config_radio="${station_id%%/*}"
                        config_essid="${station_id%/*}"
@@ -847,50 +777,43 @@ f_main()
                        uci_commit "wireless"
                        f_check "dev" "false"
                fi
-               f_log "debug" "f_main    ::: radio_list: ${trm_radiolist}, sta_list: ${trm_stalist:0:${trm_scanbuffer}}"
+               f_log "debug" "f_main    ::: radio_list: ${trm_radiolist}, sta_list: ${trm_stalist:0:trm_scanbuffer}"
 
                # radio loop
                #
-               for radio in ${trm_radiolist}
-               do
-                       if [ -z "$(printf "%s" "${trm_stalist}" | grep -o "\\-${radio}")" ]
-                       then
+               for radio in ${trm_radiolist}; do
+                       if ! printf "%s" "${trm_stalist}" | grep -q "\\-${radio}"; then
                                f_log "info" "no station on radio '${radio}'"
                                continue
                        fi
 
                        # station loop
                        #
-                       for sta in ${trm_stalist}
-                       do
+                       for sta in ${trm_stalist}; do
                                section="${sta%%-*}"
                                sta_radio="$(uci_get "wireless" "${section}" "device")"
                                sta_essid="$(uci_get "wireless" "${section}" "ssid")"
                                sta_bssid="$(uci_get "wireless" "${section}" "bssid")"
                                sta_iface="$(uci_get "wireless" "${section}" "network")"
                                sta_mac="$(f_mac "get" "${section}")"
-                               if [ -z "${sta_radio}" ] || [ -z "${sta_essid}" ] || [ -z "${sta_iface}" ]
-                               then
+                               if [ -z "${sta_radio}" ] || [ -z "${sta_essid}" ] || [ -z "${sta_iface}" ]; then
                                        f_log "info" "invalid wireless section '${section}'"
                                        continue
                                fi
-                               if [ "${sta_radio}" = "${config_radio}" ] && [ "${sta_essid}" = "${config_essid}" ] && [ "${sta_bssid}" = "${config_bssid}" ]
-                               then
+                               if [ "${sta_radio}" = "${config_radio}" ] && [ "${sta_essid}" = "${config_essid}" ] && [ "${sta_bssid}" = "${config_bssid}" ]; then
                                        f_contrack "refresh" "${config_radio}" "${config_essid}" "${config_bssid}"
                                        f_log "info" "uplink still in range '${config_radio}/${config_essid}/${config_bssid:-"-"}' with mac '${sta_mac:-"-"}'"
                                        break 2
                                fi
                                f_log "debug" "f_main    ::: sta_radio: ${sta_radio}, sta_essid: \"${sta_essid}\", sta_bssid: ${sta_bssid:-"-"}"
-                               if [ -z "${scan_list}" ]
-                               then
-                                       scan_dev="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -l1 -e "@.${radio}.interfaces[0].ifname")"
-                                       scan_list="$("${trm_iwinfo}" "${scan_dev:-${radio}}" scan 2>/dev/null | \
+                               if [ -z "${scan_list}" ]; then
+                                       scan_dev="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e "@.${radio}.interfaces[0].ifname")"
+                                       scan_list="$("${trm_iwinfo}" "${scan_dev:-${radio}}" scan 2>/dev/null |
                                                awk 'BEGIN{FS="[[:space:]]"}/Address:/{var1=$NF}/ESSID:/{var2="";for(i=12;i<=NF;i++)if(var2==""){var2=$i}else{var2=var2" "$i};
-                                               gsub(/,/,".",var2)}/Quality:/{split($NF,var0,"/")}/Encryption:/{if($NF=="none"){var3="+"}else{var3="-"};printf "%i,%s,%s,%s\n",(var0[1]*100/var0[2]),var1,var2,var3}' | \
+                                               gsub(/,/,".",var2)}/Quality:/{split($NF,var0,"/")}/Encryption:/{if($NF=="none"){var3="+"}else{var3="-"};printf "%i,%s,%s,%s\n",(var0[1]*100/var0[2]),var1,var2,var3}' |
                                                sort -rn | awk -v buf="${trm_scanbuffer}" 'BEGIN{ORS=","}{print substr($0,1,buf)}')"
                                        f_log "debug" "f_main    ::: radio: ${radio}, scan_device: ${scan_dev}, scan_buffer: ${trm_scanbuffer}, scan_list: ${scan_list:-"-"}"
-                                       if [ -z "${scan_list}" ]
-                                       then
+                                       if [ -z "${scan_list}" ]; then
                                                f_log "info" "no scan results on '${radio}'"
                                                continue 2
                                        fi
@@ -899,32 +822,31 @@ f_main()
                                # scan loop
                                #
                                IFS=","
-                               for spec in ${scan_list}
-                               do
-                                       if [ -z "${scan_quality}" ]
-                                       then
+                               for spec in ${scan_list}; do
+                                       if [ -z "${scan_quality}" ]; then
                                                scan_quality="${spec}"
-                                       elif [ -z "${scan_bssid}" ]
-                                       then
+                                       elif [ -z "${scan_bssid}" ]; then
                                                scan_bssid="${spec}"
-                                       elif [ -z "${scan_essid}" ]
-                                       then
+                                       elif [ -z "${scan_essid}" ]; then
                                                scan_essid="${spec}"
-                                       elif [ -z "${scan_open}" ]
-                                       then
+                                       elif [ -z "${scan_open}" ]; then
                                                scan_open="${spec}"
                                        fi
-                                       if [ -n "${scan_quality}" ] && [ -n "${scan_bssid}" ] && [ -n "${scan_essid}" ] && [ -n "${scan_open}" ]
-                                       then
-                                               if [ "${scan_quality}" -ge "${trm_minquality}" ]
-                                               then
-                                                       if { { [ "${scan_essid}" = "\"${sta_essid//,/.}\"" ] && { [ -z "${sta_bssid}" ] || [ "${scan_bssid}" = "${sta_bssid}" ]; } } || \
-                                                               { [ "${scan_bssid}" = "${sta_bssid}" ] && [ "${scan_essid}" = "unknown" ]; } } && [ "${radio}" = "${sta_radio}" ]
-                                                       then
+                                       if [ -n "${scan_quality}" ] && [ -n "${scan_bssid}" ] && [ -n "${scan_essid}" ] && [ -n "${scan_open}" ]; then
+                                               if [ "${scan_quality}" -ge "${trm_minquality}" ]; then
+                                                       if {
+                                                               {
+                                                                       [ "${scan_essid}" = "\"${sta_essid//,/.}\"" ] && {
+                                                                               [ -z "${sta_bssid}" ] || [ "${scan_bssid}" = "${sta_bssid}" ]
+                                                                       }
+                                                               } ||
+                                                                       {
+                                                                               [ "${scan_bssid}" = "${sta_bssid}" ] && [ "${scan_essid}" = "unknown" ]
+                                                                       }
+                                                       } && [ "${radio}" = "${sta_radio}" ]; then
                                                                f_vpn "disable"
                                                                f_log "debug" "f_main    ::: scan_quality: ${scan_quality}, scan_essid: ${scan_essid}, scan_bssid: ${scan_bssid:-"-"}, scan_open: ${scan_open}"
-                                                               if [ -n "${config_radio}" ]
-                                                               then
+                                                               if [ -n "${config_radio}" ]; then
                                                                        uci_set "wireless" "${trm_activesta}" "disabled" "1"
                                                                        uci_commit "wireless"
                                                                        f_contrack "end" "${config_radio}" "${config_essid}" "${config_bssid}"
@@ -936,22 +858,18 @@ f_main()
                                                                #
                                                                retrycnt=1
                                                                trm_radio="${sta_radio}"
-                                                               while [ "${retrycnt}" -le "${trm_maxretry}" ]
-                                                               do
-                                                                       if [ "${trm_randomize}" = "1" ]
-                                                                       then
+                                                               while [ "${retrycnt}" -le "${trm_maxretry}" ]; do
+                                                                       if [ "${trm_randomize}" = "1" ]; then
                                                                                sta_mac="$(f_mac "set" "${section}")"
                                                                        fi
                                                                        uci_set "wireless" "${section}" "disabled" "0"
                                                                        f_check "sta" "false" "${sta_radio}" "${sta_essid}" "${sta_bssid}"
-                                                                       if [ "${trm_ifstatus}" = "true" ]
-                                                                       then
+                                                                       if [ "${trm_ifstatus}" = "true" ]; then
                                                                                unset IFS scan_list
                                                                                rm -f "${trm_mailfile}"
                                                                                uci_commit "wireless"
                                                                                f_contrack "start" "${sta_radio}" "${sta_essid}" "${sta_bssid}"
-                                                                               if [ "${trm_randomize}" = "0" ]
-                                                                               then
+                                                                               if [ "${trm_randomize}" = "0" ]; then
                                                                                        sta_mac="$(f_mac "get" "${section}")"
                                                                                fi
                                                                                f_log "info" "connected to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' with mac '${sta_mac:-"-"}' (${retrycnt}/${trm_maxretry})"
@@ -959,8 +877,7 @@ f_main()
                                                                        else
                                                                                uci -q revert "wireless"
                                                                                f_check "rev" "false"
-                                                                               if [ "${retrycnt}" = "${trm_maxretry}" ]
-                                                                               then
+                                                                               if [ "${retrycnt}" = "${trm_maxretry}" ]; then
                                                                                        f_contrack "disabled" "${sta_radio}" "${sta_essid}" "${sta_bssid}"
                                                                                        f_log "info" "uplink has been disabled '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${retrycnt}/${trm_maxretry})"
                                                                                        break 2
@@ -969,11 +886,10 @@ f_main()
                                                                                        f_log "info" "can't connect to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${retrycnt}/${trm_maxretry})"
                                                                                fi
                                                                        fi
-                                                                       retrycnt="$((retrycnt+1))"
-                                                                       sleep "$((trm_maxwait/6))"
+                                                                       retrycnt="$((retrycnt + 1))"
+                                                                       sleep "$((trm_maxwait / 6))"
                                                                done
-                                                       elif [ "${trm_autoadd}" = "1" ] && [ "${scan_open}" = "+" ] && [ "${scan_essid}" != "unknown" ]
-                                                       then
+                                                       elif [ "${trm_autoadd}" = "1" ] && [ "${scan_open}" = "+" ] && [ "${scan_essid}" != "unknown" ]; then
                                                                scan_essid="${scan_essid%?}"
                                                                scan_essid="${scan_essid:1}"
                                                                f_addif "${sta_radio}" "${scan_essid}"
@@ -995,8 +911,7 @@ f_main()
 
 # source required system libraries
 #
-if [ -r "/lib/functions.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]
-then
+if [ -r "/lib/functions.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then
        . "/lib/functions.sh"
        . "/usr/share/libubox/jshn.sh"
 else
@@ -1005,39 +920,32 @@ fi
 
 # control travelmate actions
 #
-if [ "${trm_action}" != "stop" ]
-then
+if [ "${trm_action}" != "stop" ]; then
        f_env
 fi
-while true
-do
-       if [ -z "${trm_action}" ]
-       then
+while true; do
+       if [ -z "${trm_action}" ]; then
                rc=0
-               while true
-               do
-                       if [ "${rc}" = "0" ]
-                       then
+               while true; do
+                       if [ "${rc}" = "0" ]; then
                                f_check "initial" "false"
                        fi
                        sleep "${trm_timeout}" 0
                        rc=${?}
-                       if [ "${rc}" != "0" ]
-                       then
+                       if [ "${rc}" != "0" ]; then
                                f_check "initial" "false"
                        fi
-                       if [ "${rc}" = "0" ] || { [ "${rc}" != "0" ] && [ "${trm_ifstatus}" = "false" ]; }
-                       then
+                       if [ "${rc}" = "0" ] || {
+                               [ "${rc}" != "0" ] && [ "${trm_ifstatus}" = "false" ]
+                       }; then
                                break
                        fi
                done
-       elif [ "${trm_action}" = "stop" ]
-       then
-               if [ -s "${trm_pidfile}" ]
-               then
+       elif [ "${trm_action}" = "stop" ]; then
+               if [ -s "${trm_pidfile}" ]; then
                        f_log "info" "travelmate instance stopped ::: action: ${trm_action}, pid: $(cat ${trm_pidfile} 2>/dev/null)"
-                       "${trm_rtfile}"
-                       "${trm_pidfile}"
+                       : >"${trm_rtfile}"
+                       : >"${trm_pidfile}"
                fi
                break
        else
index 94da997a13fb92adedc8c11f19e47698b35d9427..3ee18fea7f48c0266d555b94398ca2ae2a3ce0ae 100755 (executable)
@@ -1,10 +1,10 @@
 #!/bin/sh
 # vpn switch for travelmate
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,3040,3043
 
 # Please note: you have to setup the package 'wireguard' or 'openvpn' before using this script
 
@@ -12,9 +12,10 @@ export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
-       . "/lib/functions.sh"
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+    . "/lib/functions.sh"
 fi
 
 vpn_action="${1}"
@@ -22,129 +23,93 @@ trm_vpnservice="$(uci_get travelmate global trm_vpnservice)"
 trm_vpniface="$(uci_get travelmate global trm_vpniface)"
 trm_landevice="$(uci_get travelmate global trm_landevice)"
 trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
-trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://captive.apple.com")"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
+trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
 trm_iptrule_accept="FORWARD -i ${trm_landevice} -p tcp  --match multiport --dports 80,443 -j ACCEPT"
 trm_iptrule_drop="FORWARD -i ${trm_landevice} -j DROP"
 trm_iptables="$(command -v iptables)"
 trm_logger="$(command -v logger)"
 trm_fetch="$(command -v curl)"
 
-f_log()
-{
-       local class="${1}" log_msg="${2}"
-
-       if [ -x "${trm_logger}" ]
-       then
-               "${trm_logger}" -p "${class}" -t "trm-vpn  [${$}]" "${log_msg}"
-       else
-               printf "%s %s %s\\n" "${class}" "trm-vpn  [${$}]" "${log_msg}"
-       fi
-}
-
 f_net()
 {
-       local IFS json_raw json_rc result="net nok"
+       local IFS json_rc result="net nok"
 
-       json_raw="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --write-out "%{json}" --silent --show-error --connect-timeout $((trm_maxwait/10)) "${trm_captiveurl}" 2>/dev/null)"
-       json_raw="${json_raw#*\{}"
-       if [ -n "${json_raw}" ]
-       then
-               json_rc="$(printf "%s" "{${json_raw}" | jsonfilter -l1 -e '@.response_code' 2>/dev/null)"
-               if [ "${json_rc}" = "200" ] || [ "${json_rc}" = "204" ]
-               then
-                       result="net ok"
-               fi
+       json_rc="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 10)) --header "Cache-Control: no-cache, no-store, must-revalidate" --header "Pragma: no-cache" --header "Expires: 0" --write-out "%{response_code}" --silent --show-error --output /dev/null "${trm_captiveurl}")"
+       if [ "${json_rc}" = "200" ] || [ "${json_rc}" = "204" ]; then
+               result="net ok"
        fi
        printf "%s" "${result}"
 }
 
-if [ -n "${trm_vpnservice}" ] && [ -n "${trm_vpniface}" ] && [ -n "${trm_landevice}" ] && [ -f "/tmp/trm_runtime.json" ]
-then
+if [ -n "${trm_vpnservice}" ] && [ -n "${trm_vpniface}" ] && [ -n "${trm_landevice}" ] && [ -f "/tmp/trm_runtime.json" ]; then
        status="$(jsonfilter -i "/tmp/trm_runtime.json" -l1 -e '@.data.travelmate_status' 2>/dev/null)"
        vpn_status="$(ubus -S call network.interface."${trm_vpniface}" status 2>/dev/null | jsonfilter -l1 -e '@.up')"
-       if [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
-       then
-               if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_drop} 2>&1)" ] && \
-                       [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_accept} 2>&1)" ]
-               then
-                       "${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_drop} 2>&1
-                       f_log "info" "lan forward blocked for device '${trm_landevice}'"
+       if [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]; then
+               if [ -n "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_drop}" 2>&1)" ] &&
+                       [ -n "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_accept}" 2>&1)" ]; then
+                       "${trm_iptables}" "-w $((trm_maxwait / 6))" -I "${trm_iptrule_drop}" 2>&1
+                       "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "lan forward blocked for device '${trm_landevice}'"  2>/dev/null
                fi
        fi
-       if [ "${vpn_action}" = "disable" ] && [ "${status%% (net cp *}" = "connected" ]
-       then
-               if [ -n "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_accept} 2>&1)" ] && \
-                       [ -z "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_drop} 2>&1)" ]
-               then
-                       "${trm_iptables}" "-w $((trm_maxwait/6))" -I ${trm_iptrule_accept} 2>&1
-                       f_log "info" "lan forward on ports 80/443 freed for device '${trm_landevice}'"
+       if [ "${vpn_action}" = "disable" ] && [ "${status%% (net cp *}" = "connected" ]; then
+               if [ -n "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_accept}" 2>&1)" ] &&
+                       [ -z "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_drop}" 2>&1)" ]; then
+                       "${trm_iptables}" "-w $((trm_maxwait / 6))" -I "${trm_iptrule_accept}" 2>&1
+                       "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "lan forward on ports 80/443 freed for device '${trm_landevice}'"  2>/dev/null
                fi
        fi
 
        case "${trm_vpnservice}" in
                "wireguard")
-                       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
-                       then
+                       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]; then
                                ubus call network.interface."${trm_vpniface}" up
-                       elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
-                       then
+                       elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]; then
                                ubus call network.interface."${trm_vpniface}" down
-                               f_log "info" "${trm_vpnservice} client connection disabled"
+                               "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "${trm_vpnservice} client connection disabled"  2>/dev/null
                        fi
-               ;;
+                       ;;
                "openvpn")
-                       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
-                       then
+                       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]; then
                                ubus call network.interface."${trm_vpniface}" up
                                /etc/init.d/openvpn restart >/dev/null 2>&1
-                       elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]
-                       then
+                       elif [ "${vpn_action}" = "disable" ] && [ "${vpn_status}" = "true" ]; then
                                ubus call network.interface."${trm_vpniface}" down
                                /etc/init.d/openvpn stop >/dev/null 2>&1
-                               f_log "info" "${trm_vpnservice} client connection disabled"
+                               "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "${trm_vpnservice} client connection disabled"  2>/dev/null
                        fi
-               ;;
+                       ;;
        esac
 
-       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]
-       then
+       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" != "true" ]; then
                cnt=0
-               while true
-               do
+               while true; do
                        vpn_status="$(ubus -S call network.interface."${trm_vpniface}" status 2>/dev/null | jsonfilter -l1 -e '@.up')"
-                       if [ "${vpn_status}" = "true" ]
-                       then
+                       if [ "${vpn_status}" = "true" ]; then
                                net_status="$(f_net)"
-                               if [ "${net_status}" = "net ok" ]
-                               then
-                                       f_log "info" "${trm_vpnservice} client connection enabled"
-                                       if [ -z "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_drop} 2>&1)" ]
-                                       then
-                                               "${trm_iptables}" "-w $((trm_maxwait/6))" -D ${trm_iptrule_drop} 2>&1
-                                               if [ -z "$("${trm_iptables}" "-w $((trm_maxwait/6))" -C ${trm_iptrule_accept} 2>&1)" ]
-                                               then
-                                                       "${trm_iptables}" "-w $((trm_maxwait/6))" -D ${trm_iptrule_accept} 2>&1
+                               if [ "${net_status}" = "net ok" ]; then
+                                       "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "${trm_vpnservice} client connection enabled"  2>/dev/null
+                                       if [ -z "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_drop}" 2>&1)" ]; then
+                                               "${trm_iptables}" "-w $((trm_maxwait / 6))" -D "${trm_iptrule_drop}" 2>&1
+                                               if [ -z "$("${trm_iptables}" "-w $((trm_maxwait / 6))" -C "${trm_iptrule_accept}" 2>&1)" ]; then
+                                                       "${trm_iptables}" "-w $((trm_maxwait / 6))" -D "${trm_iptrule_accept}" 2>&1
                                                fi
-                                               f_log "info" "lan forward freed for device '${trm_landevice}'"
+                                               "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "lan forward freed for device '${trm_landevice}'"  2>/dev/null
                                        fi
                                        break
                                fi
                        fi
-                       if [ "${cnt}" -ge "$((trm_maxwait/6))" ]
-                       then
-                               f_log "info" "${trm_vpnservice} restart failed, lan forward for device '${trm_landevice}' still blocked"
+                       if [ "${cnt}" -ge "$((trm_maxwait / 6))" ]; then
+                               "${trm_logger}" -p "info" -t "trm-vpn  [${$}]" "${trm_vpnservice} restart failed, lan forward for device '${trm_landevice}' still blocked"  2>/dev/null
                                ubus call network.interface."${trm_vpniface}" down
                                exit 2
                        fi
                        sleep 1
-                       cnt="$((cnt+1))"
+                       cnt="$((cnt + 1))"
                done
        fi
-       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" = "true" ]
-       then
-               if [ -f "/etc/init.d/sysntpd" ]
-               then
+       if [ "${vpn_action}" = "enable" ] && [ "${vpn_status}" = "true" ]; then
+               if [ -f "/etc/init.d/sysntpd" ]; then
                        /etc/init.d/sysntpd restart >/dev/null 2>&1
                fi
        fi
index 2a215e4ba4a4b32194542c2847a5e22529d0fee0..6a9be8219a8f1f13cc2b5bc9a0825b6783ad803b 100755 (executable)
@@ -1,34 +1,19 @@
 #!/bin/sh
 # ntp hotplug script for travelmate
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=3023
 
 trm_init="/etc/init.d/travelmate"
 trm_ntpfile="/var/state/travelmate.ntp"
 trm_logger="$(command -v logger)"
 
-f_log()
-{
-       local class="${1}" log_msg="${2}"
-
-       if [ -x "${trm_logger}" ]
-       then
-               "${trm_logger}" -p "${class}" -t "trm-ntp  [${$}]" "${log_msg}"
-       else
-               printf "%s %s %s\\n" "${class}" "trm-ntp  [${$}]" "${log_msg}"
-       fi
-}
-
-if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ]
-then
+if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && "${trm_init}" enabled; then
        {
-               flock -xn 1001
-               if [ "$?" = "0" ]
-               then
-                       f_log "info" "get ntp time sync"
+               if flock -xn 1001; then
+                       "${trm_logger}" -p "info" -t "trm-ntp  [${$}]" "get ntp time sync" 2>/dev/null
                        "${trm_init}" restart
                fi
        } 1001>"${trm_ntpfile}"
diff --git a/net/travelmate/files/vodafone.login b/net/travelmate/files/vodafone.login
new file mode 100755 (executable)
index 0000000..17628da
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# captive portal auto-login script for vodafone hotspots (DE)
+# Copyright (c) 2021 Dirk Brenken (dev@brenken.org)
+# This is free software, licensed under the GNU General Public License v3.
+
+# set (s)hellcheck exceptions
+# shellcheck disable=1091,3040
+
+export LC_ALL=C
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+set -o pipefail
+
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+       . "/lib/functions.sh"
+fi
+
+username="${1}"
+password="${2}"
+trm_domain="hotspot.vodafone.de"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
+trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
+trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
+trm_fetch="$(command -v curl)"
+
+# get sid
+#
+raw_html="$(${trm_fetch} --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --write-out "%{redirect_url}" --silent --show-error --output /dev/null "${trm_captiveurl}")"
+sid="$(printf "%s" "${raw_html}" 2>/dev/null | awk 'BEGIN{FS="[=&]"}{printf "%s",$2}')"
+if [ -z "${sid}" ]; then
+       exit 1
+fi
+
+# get session
+#
+raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --silent --connect-timeout $((trm_maxwait / 6)) "https://${trm_domain}/api/v4/session?sid=${sid}")"
+session="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.session')"
+if [ -z "${session}" ]; then
+       exit 2
+fi
+
+# final login request
+#
+raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://${trm_domain}/portal/?sid=${sid}" --silent --connect-timeout $((trm_maxwait / 6)) --data "accessType=csc-community&accountType=csc&loginProfile=4&password=${password}&session=${session}&username=${username}&save=true" "https://${trm_domain}/api/v4/login?sid=${sid}")"
+success="$(printf "%s" "${raw_html}" 2>/dev/null | jsonfilter -q -l1 -e '@.success')"
+if [ "${success}" != "true" ]; then
+       exit 3
+fi
index c74a2bf14d66e3304c783981f6c7d15360116597..316c7470138eccd6b679235fcbc650f8dc2b5820 100755 (executable)
@@ -1,41 +1,38 @@
 #!/bin/sh
-# captive portal auto-login script for german ICE hotspots
-# Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
+# captive portal auto-login script for ICE hotspots (DE)
+# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
 # set (s)hellcheck exceptions
-# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
+# shellcheck disable=1091,2181,3040
 
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
 
-if [ "$(uci_get 2>/dev/null; printf "%u" "${?}")" = "127" ]
-then
-       . "/lib/functions.sh"
+# source function library if necessary
+#
+if [ -z "${_C}" ]; then
+    . "/lib/functions.sh"
 fi
 
 trm_domain="www.wifionice.de"
-trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0")"
+trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
 trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
 trm_fetch="$(command -v curl)"
 
-# initial get request to receive & extract a valid security token
+# get security token
 #
-"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait/6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}/en/"
-if [ -f "/tmp/${trm_domain}.cookie" ]
-then
-       sec_token="$(awk '/csrf/{print $7}' "/tmp/${trm_domain}.cookie")"
-       rm -f "/tmp/${trm_domain}.cookie"
-else
-       exit 2
+"${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --silent --connect-timeout $((trm_maxwait / 6)) --cookie-jar "/tmp/${trm_domain}.cookie" --output /dev/null "http://${trm_domain}/en/"
+sec_token="$(awk '/csrf/{print $7}' "/tmp/${trm_domain}.cookie" 2>/dev/null)"
+rm -f "/tmp/${trm_domain}.cookie"
+if [ -z "${sec_token}" ]; then
+       exit 1
 fi
 
-# final post request/login with valid session cookie/security token
+# final post request
 #
-if [ -n "${sec_token}" ]
-then
-       "${trm_fetch}" --user-agent "${trm_useragent}" --silent --connect-timeout $((trm_maxwait/6)) --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}&connect=" --output /dev/null "http://${trm_domain}/en/"
-else
-       exit 3
+"${trm_fetch}" --user-agent "${trm_useragent}" --silent --connect-timeout $((trm_maxwait / 6)) --header "Cookie: csrf=${sec_token}" --data "login=true&CSRFToken=${sec_token}&connect=" --output /dev/null "http://${trm_domain}/en/"
+if [ "${?}" != "0" ]; then
+       exit 2
 fi
index b15a145d457a45061d1578de0537ea9323a69662..ca276fb36ffd37d2fb27c2ab13cb1ccff73f5dd2 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=bash
-PKG_VERSION:=5.1
-PKG_RELEASE:=3
+PKG_VERSION:=5.1.8
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@GNU/bash
-PKG_HASH:=cc012bc860406dcf42f64431bcd3d2fa7560c02915a601aba9cd597a39329baa
+PKG_HASH:=0cfb5c9bb1a29f800a97bd242d19511c997a1013815b805e0fdd32214113d6be
 
 PKG_MAINTAINER:=Marcel Denia <naoir@gmx.net>
 PKG_LICENSE:=GPL-3.0-or-later
diff --git a/utils/bash/patches/101-bash51-001.patch b/utils/bash/patches/101-bash51-001.patch
deleted file mode 100644 (file)
index 02898aa..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-                            BASH PATCH REPORT
-                            =================
-
-Bash-Release:  5.1
-Patch-ID:      bash51-001
-
-Bug-Reported-by:       Fazal Majid <fazal@majid.org>
-Bug-Reference-ID:      <DEAB7D2C-C626-450C-B2E5-281AFF2D26D4@majid.org>
-Bug-Reference-URL:     https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00000.html
-
-Bug-Description:
-
-There is a missing dependency on a constructed file, which can cause highly
-parellel builds to fail.
-
-Patch (apply with `patch -p0'):
-
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -1315,6 +1315,7 @@ bashline.o: trap.h flags.h assoc.h $(BAS
- bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
- bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
- bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-+bashline.o: ${DEFDIR}/builtext.h
- bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
- bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
- bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h
-@@ -1435,6 +1436,7 @@ builtins/evalstring.o: quit.h unwind_pro
- builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h 
- builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
- builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h
-+builtins/evalstring.o: ${DEFDIR}/builtext.h
- builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
- builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
- builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
---- a/builtins/Makefile.in
-+++ b/builtins/Makefile.in
-@@ -361,7 +361,7 @@ evalstring.o: $(topdir)/dispose_cmd.h $(
- evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
- evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
- evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
--evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h
-+evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h ./builtext.h
- #evalstring.o: $(topdir)/y.tab.h
- getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
- getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h
---- a/patchlevel.h
-+++ b/patchlevel.h
-@@ -1,6 +1,6 @@
- /* patchlevel.h -- current bash patch level */
--/* Copyright (C) 2001-2016 Free Software Foundation, Inc.
-+/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
-    This file is part of GNU Bash, the Bourne Again SHell.
-@@ -25,6 +25,6 @@
-    regexp `^#define[  ]*PATCHLEVEL', since that's what support/mkversion.sh
-    looks for to find the patch level (for the sccs version string). */
--#define PATCHLEVEL 0
-+#define PATCHLEVEL 1
- #endif /* _PATCHLEVEL_H_ */
diff --git a/utils/bash/patches/102-bash51-002.patch b/utils/bash/patches/102-bash51-002.patch
deleted file mode 100644 (file)
index 2faa881..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-                            BASH PATCH REPORT
-                            =================
-
-Bash-Release:  5.1
-Patch-ID:      bash51-002
-
-Bug-Reported-by:       oguzismailuysal@gmail.com
-Bug-Reference-ID:      <CAH7i3LoHFUa4aSF5-AD2r80HG-p-YzD_9ZxomarZkhP8NMq63g@mail.gmail.com>
-Bug-Reference-URL:     https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00037.html
-
-Bug-Description:
-
-If there are no jobs, and the `-n' and `-p' options are both supplied to
-`wait', bash can assign a value to the variable name specified with `-p'
-instead of leaving it unset.
-
-Patch (apply with `patch -p0'):
-
---- a/builtins/wait.def
-+++ b/builtins/wait.def
-@@ -213,11 +213,11 @@ wait_builtin (list)
-       }
-       status = wait_for_any_job (wflags, &pstat);
--      if (status < 0)
--      status = 127;
--
-       if (vname && status >= 0)
-       bind_var_to_int (vname, pstat.pid);
-+
-+      if (status < 0)
-+      status = 127;
-       if (list)
-       unset_waitlist ();
-       WAIT_RETURN (status);
---- a/patchlevel.h
-+++ b/patchlevel.h
-@@ -25,6 +25,6 @@
-    regexp `^#define[  ]*PATCHLEVEL', since that's what support/mkversion.sh
-    looks for to find the patch level (for the sccs version string). */
--#define PATCHLEVEL 1
-+#define PATCHLEVEL 2
- #endif /* _PATCHLEVEL_H_ */
diff --git a/utils/bash/patches/103-bash51-003.patch b/utils/bash/patches/103-bash51-003.patch
deleted file mode 100644 (file)
index 72c251b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-                            BASH PATCH REPORT
-                            =================
-
-Bash-Release:  5.1
-Patch-ID:      bash51-003
-
-Bug-Reported-by:       oguzismailuysal@gmail.com
-Bug-Reference-ID:      <CAH7i3LpG91BnNcDtaTUm2Ph7a+PnJkuh6nAc87cVL7_38tOaMQ@mail.gmail.com>
-Bug-Reference-URL:     https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00050.html
-
-Bug-Description:
-
-Bash does not put a command substitution process that is started to perform an
-expansion in a child process into the right process group where it can receive
-keyboard-generated signals.
-
-Patch (apply with `patch -p0'):
-
---- a/subst.c
-+++ b/subst.c
-@@ -6356,8 +6356,10 @@ command_substitute (string, quoted, flag
- #if defined (JOB_CONTROL)
-   old_pipeline_pgrp = pipeline_pgrp;
--  /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline. */
--  if ((subshell_environment & SUBSHELL_PIPE) == 0)
-+  /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline or
-+     we've already forked to run a disk command (and are expanding redirections,
-+     for example). */
-+  if ((subshell_environment & (SUBSHELL_FORK|SUBSHELL_PIPE)) == 0)
-     pipeline_pgrp = shell_pgrp;
-   cleanup_the_pipeline ();
- #endif /* JOB_CONTROL */
---- a/patchlevel.h
-+++ b/patchlevel.h
-@@ -25,6 +25,6 @@
-    regexp `^#define[  ]*PATCHLEVEL', since that's what support/mkversion.sh
-    looks for to find the patch level (for the sccs version string). */
--#define PATCHLEVEL 2
-+#define PATCHLEVEL 3
- #endif /* _PATCHLEVEL_H_ */
diff --git a/utils/bash/patches/104-bash51-004.patch b/utils/bash/patches/104-bash51-004.patch
deleted file mode 100644 (file)
index 218b843..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-                            BASH PATCH REPORT
-                            =================
-
-Bash-Release:  5.1
-Patch-ID:      bash51-004
-
-Bug-Reported-by:       oguzismailuysal@gmail.com
-Bug-Reference-ID:      <CAH7i3LoHGmwaghDpCWRUfcY04gQmeDTH3RiG=bf2b=KbU=gyhw@mail.gmail.com>
-Bug-Reference-URL:     https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00039.html
-
-Bug-Description:
-
-If a key-value compound array assignment to an associative array is supplied
-as an assignment statement argument to the `declare' command that declares the
-array, the assignment doesn't perform the correct word expansions.
-
-This patch makes key-value assignment and subscript assignment perform the
-same expansions when they're supplied as an argument to `declare'.
-
-Patch (apply with `patch -p0'):
-
---- a/arrayfunc.c
-+++ b/arrayfunc.c
-@@ -597,6 +597,27 @@ assign_assoc_from_kvlist (var, nlist, h,
-       free (aval);
-     }
- }
-+
-+/* Return non-zero if L appears to be a key-value pair associative array
-+   compound assignment. */ 
-+int
-+kvpair_assignment_p (l)
-+     WORD_LIST *l;
-+{
-+  return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '[');      /*]*/
-+}
-+
-+char *
-+expand_and_quote_kvpair_word (w)
-+     char *w;
-+{
-+  char *t, *r;
-+
-+  t = w ? expand_assignment_string_to_string (w, 0) : 0;
-+  r = sh_single_quote (t ? t : "");
-+  free (t);
-+  return r;
-+}
- #endif
-      
- /* Callers ensure that VAR is not NULL. Associative array assignments have not
-@@ -640,7 +661,7 @@ assign_compound_array_list (var, nlist,
-   last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
- #if ASSOC_KVPAIR_ASSIGNMENT
--  if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[')      /*]*/
-+  if (assoc_p (var) && kvpair_assignment_p (nlist))
-     {
-       iflags = flags & ~ASS_APPEND;
-       assign_assoc_from_kvlist (var, nlist, nhash, iflags);
---- a/arrayfunc.h
-+++ b/arrayfunc.h
-@@ -67,6 +67,9 @@ extern SHELL_VAR *assign_array_var_from_
- extern char *expand_and_quote_assoc_word PARAMS((char *, int));
- extern void quote_compound_array_list PARAMS((WORD_LIST *, int));
-+extern int kvpair_assignment_p PARAMS((WORD_LIST *));
-+extern char *expand_and_quote_kvpair_word PARAMS((char *));
-+
- extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int));
- extern int skipsubscript PARAMS((const char *, int, int));
---- a/subst.c
-+++ b/subst.c
-@@ -11604,6 +11604,7 @@ expand_oneword (value, flags)
- {
-   WORD_LIST *l, *nl;
-   char *t;
-+  int kvpair;
-   
-   if (flags == 0)
-     {
-@@ -11618,11 +11619,21 @@ expand_oneword (value, flags)
-     {
-       /* Associative array */
-       l = parse_string_to_word_list (value, 1, "array assign");
-+#if ASSOC_KVPAIR_ASSIGNMENT
-+      kvpair = kvpair_assignment_p (l);
-+#endif
-+
-       /* For associative arrays, with their arbitrary subscripts, we have to
-        expand and quote in one step so we don't have to search for the
-        closing right bracket more than once. */
-       for (nl = l; nl; nl = nl->next)
-       {
-+#if ASSOC_KVPAIR_ASSIGNMENT
-+        if (kvpair)
-+          /* keys and values undergo the same set of expansions */
-+          t = expand_and_quote_kvpair_word (nl->word->word);
-+        else
-+#endif
-         if ((nl->word->flags & W_ASSIGNMENT) == 0)
-           t = sh_single_quote (nl->word->word ? nl->word->word : "");
-         else
---- a/patchlevel.h
-+++ b/patchlevel.h
-@@ -25,6 +25,6 @@
-    regexp `^#define[  ]*PATCHLEVEL', since that's what support/mkversion.sh
-    looks for to find the patch level (for the sccs version string). */
--#define PATCHLEVEL 3
-+#define PATCHLEVEL 4
- #endif /* _PATCHLEVEL_H_ */
index 3e3c89b73553c833b113a47f7c0ab37cfc40019c..6d3407eccce806b1b784f2d369627fb842d1ca84 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=bluez
-PKG_VERSION:=5.56
-PKG_RELEASE:=1
+PKG_VERSION:=5.60
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/bluetooth/
-PKG_HASH:=59c4dba9fc8aae2a6a5f8f12f19bc1b0c2dc27355c7ca3123eed3fe6bd7d0b9d
+PKG_HASH:=710999580d01ee59ec585e5e7c07fd94eddedc001aa26fe7464c546f9d945304
 
 PKG_LICENSE:=GPL-2.0-or-later
 PKG_LICENSE_FILES:=COPYING
index 0a2f20eb32e8eec166d11f67b2b3179b7f97cdb8..f6dd7166244cee1642f83449de2bb2511891aa39 100644 (file)
@@ -1,6 +1,6 @@
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -3225,7 +3225,7 @@ unit_tests = $(am__append_54) unit/test-
+@@ -3326,7 +3326,7 @@ unit_tests = $(am__append_52) unit/test-
  @CLIENT_TRUE@                                 client/gatt.h client/gatt.c
  
  @CLIENT_TRUE@client_bluetoothctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
@@ -9,7 +9,7 @@
  
  @ZSH_COMPLETIONS_TRUE@zshcompletiondir = $(ZSH_COMPLETIONDIR)
  @ZSH_COMPLETIONS_TRUE@dist_zshcompletion_DATA = completion/zsh/_bluetoothctl
-@@ -3457,7 +3457,7 @@ unit_tests = $(am__append_54) unit/test-
+@@ -3559,7 +3559,7 @@ unit_tests = $(am__append_52) unit/test-
  
  @MESH_TRUE@@TOOLS_TRUE@tools_meshctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
  @MESH_TRUE@@TOOLS_TRUE@                               lib/libbluetooth-internal.la \
@@ -18,7 +18,7 @@
  
  @MESH_TRUE@@TOOLS_TRUE@tools_mesh_cfgclient_SOURCES = tools/mesh-cfgclient.c \
  @MESH_TRUE@@TOOLS_TRUE@                               tools/mesh/model.h tools/mesh/config-model.h \
-@@ -3524,7 +3524,7 @@ unit_tests = $(am__append_54) unit/test-
+@@ -3630,7 +3630,7 @@ unit_tests = $(am__append_52) unit/test-
  @READLINE_TRUE@                                               tools/obex-client-tool.c
  
  @READLINE_TRUE@tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
@@ -27,7 +27,7 @@
  
  @READLINE_TRUE@tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
  @READLINE_TRUE@                                               tools/obex-server-tool.c
-@@ -3533,15 +3533,15 @@ unit_tests = $(am__append_54) unit/test-
+@@ -3639,15 +3639,15 @@ unit_tests = $(am__append_52) unit/test-
  @READLINE_TRUE@tools_bluetooth_player_SOURCES = tools/bluetooth-player.c
  @READLINE_TRUE@tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
  @READLINE_TRUE@                               src/libshared-glib.la \
@@ -46,7 +46,7 @@
  
  @DEPRECATED_TRUE@@READLINE_TRUE@attrib_gatttool_SOURCES = attrib/gatttool.c attrib/att.c attrib/gatt.c \
  @DEPRECATED_TRUE@@READLINE_TRUE@                              attrib/gattrib.c btio/btio.c \
-@@ -3550,7 +3550,7 @@ unit_tests = $(am__append_54) unit/test-
+@@ -3656,7 +3656,7 @@ unit_tests = $(am__append_52) unit/test-
  @DEPRECATED_TRUE@@READLINE_TRUE@                              client/display.h
  
  @DEPRECATED_TRUE@@READLINE_TRUE@attrib_gatttool_LDADD = lib/libbluetooth-internal.la \
index 005684add9580692db9b44d20bbfff853b8973c3..c42739ea8c1242f09e4dda79c4161610f5a2ae84 100644 (file)
@@ -34,7 +34,7 @@ This commit prevents the call to btd_adv_manager_refresh for non-LE devices.
 
 --- a/src/adapter.c
 +++ b/src/adapter.c
-@@ -557,7 +557,8 @@ static void settings_changed(struct btd_
+@@ -560,7 +560,8 @@ static void settings_changed(struct btd_
                g_dbus_emit_property_changed(dbus_conn, adapter->path,
                                        ADAPTER_INTERFACE, "Discoverable");
                store_adapter_info(adapter);
index d1d94229eb47d99b953541a9f1adfac97e921eed..741bbeb9d7967163b3b56a226377b42b98396621 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=canutils
-PKG_VERSION:=2020.12.0
-PKG_RELEASE:=1
+PKG_VERSION:=2021.06.0
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/linux-can/can-utils/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=c5c22a00ce2ea7578d7617ac0affef8f47a349be58e708780d703b979f324a2b
+PKG_HASH:=f7874457224c89f8b2eb55ab741935ddb7f1c9bc52de2642330b0799f89d1040
 PKG_BUILD_DIR:=$(BUILD_DIR)/can-utils-$(PKG_VERSION)
 
 PKG_MAINTAINER:=Anton Glukhov <anton.a.glukhov@gmail.com>
index fd623c4a71109333b8677122d9cba2edc18d5b13..c17f27595b7a5c75ea6f5357553cc684d80bfee5 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=cryptsetup
-PKG_VERSION:=2.3.5
+PKG_VERSION:=2.3.6
 PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/cryptsetup/v2.3
-PKG_HASH:=ced9946f444d132536daf92fc8aca4277638a3c2d96e20540b2bae4d36fd70c1
+PKG_HASH:=b296b7a21ea576c2b180611ccb19d06aec8dddaedf7c704b0c6a81210c25635f
 
 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
 PKG_LICENSE:=GPL-2.0-or-later LGPL-2.1-or-later
index 4486fc8aa3302a8a37bf44ea3b83e7d1947bce76..28fcf926753682ffc63c76a799625b6c8a218b16 100644 (file)
@@ -1,12 +1,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ctop
-PKG_VERSION:=0.7.5
+PKG_VERSION:=0.7.6
 PKG_RELEASE:=1
 
 PKG_SOURCE:=v$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/bcicen/ctop/archive
-PKG_HASH:=a9a3be0e5eab2fee6b44a5d063188a354f9c0dde3d96a169d1490981f7826e9a
+PKG_HASH:=8ef76a7d4d725f750a5d8a6ee330e81b3b845a91fbd50ae3e746cead74736391
 
 PKG_MAINTAINER:=Javier Marcet <javier@marcet.info>
 PKG_LICENSE:=MIT
index a031c17d56bcb7c827d354246c2b015eebe60201..171c9b3f3933ac0b5d00b349fdbf59aede473611 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=rrdtool1
 PKG_VERSION:=1.0.50
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/rrdtool-$(PKG_VERSION)
 PKG_SOURCE:=rrdtool-$(PKG_VERSION).tar.gz
diff --git a/utils/rrdtool1/patches/050-no-doc.patch b/utils/rrdtool1/patches/050-no-doc.patch
new file mode 100644 (file)
index 0000000..5d450ac
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -17,7 +17,7 @@ endif
+ # build the following subdirectories
+ SUBDIRS = cgilib-0.4 gd1.3 $(SUBDIRS_1) $(SUBDIRS_2) \
+-          src doc examples contrib tcl
++          src examples contrib tcl
+ # the following files are not mentioned in any other Makefile
+ # LWT 24Jul03 - removed redundant spec file listed
index 1019eba6f019555f2ef9e2f7524c71db9598a739..a60e27468d88fd4813819cb6830008c1407f1a5b 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=spi-tools
-PKG_VERSION:=0.8.7
+PKG_VERSION:=1.0.0
 PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/cpb-/spi-tools/tar.gz/$(PKG_VERSION)?
-PKG_HASH:=550f505cc5c34a50d5cd36c49c69b2709fca3f0be4f0777e3f96a45c1ffdbd79
+PKG_HASH:=5eb24670461dcf2c58471114dc69b5204dab1c0cc5053878f6de79503bd8cc9f
 
 PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
 PKG_LICENSE:=GPL-2.0-only
index f470e51431f3084576fe3f196026d9c67de44da1..f929ba51546f655498d15738fe48927dc1a96437 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uvol
-PKG_VERSION:=0.2
+PKG_VERSION:=0.3
 PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
@@ -28,6 +28,7 @@ define Package/uvol
   CATEGORY:=Utilities
   SUBMENU:=Disc
   TITLE:=OpenWrt UBI/LVM volume abstraction
+  DEPENDS:=+blockd
   PKGARCH=all
 endef
 
@@ -63,8 +64,9 @@ define Package/autopart/install
 endef
 
 define Package/uvol/install
-       $(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/libexec/uvol $(1)/usr/sbin
+       $(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/libexec/uvol $(1)/usr/sbin $(1)/lib/functions
        $(INSTALL_BIN) ./files/uvol.init $(1)/etc/init.d/uvol
+       $(INSTALL_BIN) ./files/common.sh $(1)/lib/functions/uvol.sh
        $(INSTALL_BIN) ./files/ubi.sh $(1)/usr/libexec/uvol/20-ubi.sh
        $(INSTALL_BIN) ./files/lvm.sh $(1)/usr/libexec/uvol/50-lvm.sh
        $(INSTALL_BIN) ./files/uvol $(1)/usr/sbin
diff --git a/utils/uvol/files/common.sh b/utils/uvol/files/common.sh
new file mode 100644 (file)
index 0000000..0eee6d4
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+UCI_SPOOLDIR="/var/spool/uvol"
+
+_uvol_init_spooldir() {
+       [ ! -d "$(dirname "$UCI_SPOOLDIR")" ] && mkdir -p "$(dirname "$UCI_SPOOLDIR")"
+       mkdir -m 0700 -p "$UCI_SPOOLDIR"
+}
+
+uvol_uci_add() {
+       local volname="$1"
+       local devname="$2"
+       local mode="$3"
+       local autofs uuid uciname
+
+       uciname=${volname//-/_}
+       uuid="$(/sbin/block info | grep "^$2" | xargs -n 1 echo | grep "^UUID=.*")"
+       [ "$uuid" ] || return 22
+       _uvol_init_spooldir
+       uuid="${uuid:5}"
+       autofs=0
+       [ "$mode" = "ro" ] && autofs=1
+       if [ -e "${UCI_SPOOLDIR}/remove-$1" ]; then
+               rm "${UCI_SPOOLDIR}/remove-$1"
+       fi
+
+       cat >"${UCI_SPOOLDIR}/add-$1" <<EOF
+set fstab.$uciname=mount
+set fstab.$uciname.uuid=$uuid
+set fstab.$uciname.target=/var/run/uvol/$volname
+set fstab.$uciname.options=$mode
+set fstab.$uciname.autofs=$autofs
+set fstab.$uciname.enabled=1
+commit fstab
+EOF
+}
+
+uvol_uci_remove() {
+       local volname="$1"
+       local uciname
+
+       uciname=${volname//-/_}
+       if [ -e "${UCI_SPOOLDIR}/add-$1" ]; then
+               rm "${UCI_SPOOLDIR}/add-$1"
+               return
+       fi
+       _uvol_init_spooldir
+       cat >"${UCI_SPOOLDIR}/remove-$1" <<EOF
+delete fstab.$uciname
+commit fstab
+EOF
+}
+
+uvol_uci_commit() {
+       local volname="$1"
+
+       if [ -e "${UCI_SPOOLDIR}/add-$1" ]; then
+               uci batch < "${UCI_SPOOLDIR}/add-$1"
+               rm "${UCI_SPOOLDIR}/add-$1"
+       elif [ -e "${UCI_SPOOLDIR}/remove-$1" ]; then
+               uci batch < "${UCI_SPOOLDIR}/remove-$1"
+               rm "${UCI_SPOOLDIR}/remove-$1"
+       fi
+
+       return $?
+}
index cf808aea08fda0f052ea319b4d507438f1c906c3..c06e2f1020b4511dbf91d7128a9c942efedce295 100644 (file)
@@ -11,6 +11,7 @@ fi
 command -v lvm >/dev/null || return 1
 
 . /lib/functions.sh
+. /lib/functions/uvol.sh
 . /lib/upgrade/common.sh
 . /usr/share/libubox/jshn.sh
 
@@ -146,9 +147,20 @@ exportlv() {
 }
 
 getdev() {
+       local dms dm_name
+
+       for dms in /sys/devices/virtual/block/dm-* ; do
+               [ "$dms" = "/sys/devices/virtual/block/dm-*" ] && break
+               read -r dm_name < "$dms/dm/name"
+               [ $(basename "$lv_dm_path") = "$dm_name" ] && echo "$(basename "$dms")"
+       done
+}
+
+getuserdev() {
+       local dms dm_name
        existvol "$1" || return 1
        exportlv "$1"
-       echo "$lv_dm_path"
+       getdev "$@"
 }
 
 getsize() {
@@ -166,9 +178,9 @@ activatevol() {
                        ;;
                *)
                        [ "$lv_active" = "active" ] && return 0
-                       lvm_cmd lvchange -k n "$lv_full_name" || return $?
+                       uvol_uci_commit "$1"
                        lvm_cmd lvchange -a y "$lv_full_name" || return $?
-                       ubus send block.volume "{\"name\": \"$1\", \"action\": \"up\", \"mode\": \"${lv_name:0:2}\", \"device\": \"$lv_dm_path\"}"
+                       lvm_cmd lvchange -k n "$lv_full_name" || return $?
                        return 0
                        ;;
        esac
@@ -176,6 +188,7 @@ activatevol() {
 
 disactivatevol() {
        exportlv "$1"
+       local devname
        [ "$lv_path" ] || return 2
        case "$lv_path" in
                /dev/*/wo_*|\
@@ -184,9 +197,10 @@ disactivatevol() {
                        ;;
                *)
                        [ "$lv_active" = "active" ] || return 0
-                       lvm_cmd lvchange -a n "$lv_full_name" || return $?
+                       devname="$(getdev "$1")"
+                       [ "$devname" ] && /sbin/block umount "$devname"
+                       lvm_cmd lvchange -a n "$lv_full_name"
                        lvm_cmd lvchange -k y "$lv_full_name" || return $?
-                       ubus send block.volume "{\"name\": \"$1\", \"action\": \"down\", \"mode\": \"${lv_name:0:2}\", \"device\": \"$lv_dm_path\"}"
                        return 0
                        ;;
        esac
@@ -222,30 +236,41 @@ createvol() {
                        ;;
        esac
 
-       lvm_cmd lvcreate -p "$lvmode" -a n -y -W n -Z n -n "${mode}_$1" -l "$size_ext" "$vg_name"
+       lvm_cmd lvcreate -p "$lvmode" -a n -y -W n -Z n -n "${mode}_$1" -l "$size_ext" "$vg_name" || return $?
        ret=$?
        if [ ! $ret -eq 0 ] || [ "$lvmode" = "r" ]; then
                return $ret
        fi
        exportlv "$1"
        [ "$lv_full_name" ] || return 22
-       lvm_cmd lvchange -a y "$lv_full_name" || return 1
+       lvm_cmd lvchange -a y "$lv_full_name" || return $?
        if [ "$lv_size" -gt $(( 100 * 1024 * 1024 )) ]; then
                mkfs.f2fs -f -l "$1" "$lv_path"
                ret=$?
-               [ $ret != 0 ] && [ $ret != 134 ] && return 1
+               [ $ret != 0 ] && [ $ret != 134 ] && {
+                       lvm_cmd lvchange -a n "$lv_full_name" || return $?
+                       return $ret
+               }
        else
-               mke2fs -F -L "$1" "$lv_path" || return 1
+               mke2fs -F -L "$1" "$lv_path" || {
+                       ret=$?
+                       lvm_cmd lvchange -a n "$lv_full_name" || return $?
+                       return $ret
+               }
        fi
-       lvm_cmd lvrename "$vg_name" "wp_$1" "rw_$1"
-       exportlv "$1"
+       uvol_uci_add "$1" "/dev/$(getdev "$1")" "rw"
+       lvm_cmd lvchange -a n "$lv_full_name" || return $?
+       lvm_cmd lvrename "$vg_name" "wp_$1" "rw_$1" || return $?
        return 0
 }
 
 removevol() {
        exportlv "$1"
        [ "$lv_full_name" ] || return 2
-       lvm_cmd lvremove -y "$lv_full_name"
+       [ "$lv_active" = "active" ] && return 16
+       lvm_cmd lvremove -y "$lv_full_name" || return $?
+       uvol_uci_remove "$1"
+       uvol_uci_commit "$1"
 }
 
 updatevol() {
@@ -254,12 +279,13 @@ updatevol() {
        [ "$lv_size" -ge "$2" ] || return 27
        case "$lv_path" in
                /dev/*/wo_*)
-                       lvm_cmd lvchange -p rw "$lv_full_name"
-                       lvm_cmd lvchange -a y "$lv_full_name"
+                       lvm_cmd lvchange -p rw "$lv_full_name" || return $?
+                       lvm_cmd lvchange -a y "$lv_full_name" || return $?
                        dd of="$lv_path"
-                       lvm_cmd lvchange -a n "$lv_full_name"
-                       lvm_cmd lvchange -p r "$lv_full_name"
-                       lvm_cmd lvrename "$lv_full_name" "${lv_full_name%%/*}/ro_$1"
+                       uvol_uci_add "$1" "/dev/$(getdev "$1")" "ro"
+                       lvm_cmd lvchange -a n "$lv_full_name" || return $?
+                       lvm_cmd lvchange -p r "$lv_full_name" || return $?
+                       lvm_cmd lvrename "$lv_full_name" "${lv_full_name%%/*}/ro_$1" || return $?
                        return 0
                        ;;
                default)
@@ -308,7 +334,6 @@ boot() {
                        json_get_vars lv_name lv_dm_path
                        lv_mode="${lv_name:0:2}"
                        lv_name="${lv_name:3}"
-                       ubus send block.volume "{\"name\": \"$lv_name\", \"action\": \"up\", \"mode\": \"$lv_mode\", \"device\": \"$lv_dm_path\"}"
                        json_select ..
                done
                json_select ..
@@ -342,7 +367,7 @@ case "$cmd" in
                removevol "$@"
                ;;
        device)
-               getdev "$@"
+               getuserdev "$@"
                ;;
        size)
                getsize "$@"
index 3eb79adb95fa69a79da9c5dc98b6e25e370922f5..9ddda54da43a96f3c0b72b9e668e8b638d089bcf 100644 (file)
@@ -17,6 +17,8 @@ ubidev=$(ls -1 /sys/devices/virtual/ubi | head -n 1)
 
 read -r ebsize < "/sys/devices/virtual/ubi/${ubidev}/eraseblock_size"
 
+. /lib/functions/uvol.sh
+
 freebytes() {
        read -r availeb < "/sys/devices/virtual/ubi/${ubidev}/avail_eraseblocks"
        echo $((availeb * ebsize))
@@ -87,9 +89,10 @@ getuserdev() {
 mkubifs() {
        local tmp_mp
        tmp_mp="$(mktemp -d)"
-       mount -t ubifs "$1" "$tmp_mp"
-       umount "$tmp_mp"
-       rmdir "$tmp_mp"
+       mount -t ubifs "$1" "$tmp_mp" || return $?
+       umount "$tmp_mp" || return $?
+       rmdir "$tmp_mp" || return $?
+       return 0
 }
 
 createvol() {
@@ -107,22 +110,33 @@ createvol() {
                        return 22
                        ;;
        esac
-       ubimkvol "/dev/$ubidev" -N "uvol-$mode-$1" -s "$2"
+       ubimkvol "/dev/$ubidev" -N "uvol-$mode-$1" -s "$2" || return $?
        ret=$?
        [ $ret -eq 0 ] || return $ret
        voldev="$(getdev "$@")"
-       ubiupdatevol -t "/dev/$voldev"
+       ubiupdatevol -t "/dev/$voldev" || return $?
        [ "$mode" = "wp" ] || return 0
-       mkubifs "/dev/$voldev"
-       ubirename "/dev/$ubidev" "uvol-wp-$1" "uvol-wd-$1"
+       mkubifs "/dev/$voldev" || return $?
+       uvol_uci_add "$1" "/dev/$voldev" "rw"
+       ubirename "/dev/$ubidev" "uvol-wp-$1" "uvol-wd-$1" || return $?
 }
 
 removevol() {
-       local voldev
+       local voldev volnum
        voldev=$(getdev "$@")
        [ "$voldev" ] || return 2
-       local volnum="${voldev#${ubidev}_}"
+       vol_is_mode "$voldev" rw && return 16
+       vol_is_mode "$voldev" ro && return 16
+       volnum="${voldev#${ubidev}_}"
        ubirmvol "/dev/$ubidev" -n "$volnum" || return $?
+       uvol_uci_remove "$1"
+       uvol_uci_commit "$1"
+}
+
+block_hotplug() {
+       export ACTION="$1"
+       export DEVNAME="$2"
+       /sbin/block hotplug
 }
 
 activatevol() {
@@ -133,12 +147,15 @@ activatevol() {
        vol_is_mode "$voldev" ro && return 0
        vol_is_mode "$voldev" wo && return 22
        vol_is_mode "$voldev" wp && return 16
+       uvol_uci_commit "$1"
        if vol_is_mode "$voldev" rd; then
-               ubirename "/dev/$ubidev" "uvol-rd-$1" "uvol-ro-$1"
-               ubiblock --create "/dev/$voldev"
+               ubirename "/dev/$ubidev" "uvol-rd-$1" "uvol-ro-$1" || return $?
+               ubiblock --create "/dev/$voldev" || return $?
+               block_hotplug add "ubiblock${voldev:3}"
                return 0
        elif vol_is_mode "$voldev" wd; then
-               ubirename "/dev/$ubidev" "uvol-wd-$1" "uvol-rw-$1"
+               ubirename "/dev/$ubidev" "uvol-wd-$1" "uvol-rw-$1" || return $?
+               block_hotplug add "$voldev"
                return 0
        fi
 }
@@ -152,12 +169,14 @@ disactivatevol() {
        vol_is_mode "$voldev" wo && return 22
        vol_is_mode "$voldev" wp && return 16
        if vol_is_mode "$voldev" ro; then
-               [ -e "/dev/ubiblock${voldev:3}" ] || return 0
-               ubiblock --remove "/dev/$voldev" || return $?
+               /sbin/block umount "ubiblock${voldev:3}"
+               ubiblock --remove "/dev/$voldev"
                ubirename "/dev/$ubidev" "uvol-ro-$1" "uvol-rd-$1" || return $?
                return 0
        elif vol_is_mode "$voldev" rw; then
+               /sbin/block umount "$voldev"
                ubirename "/dev/$ubidev" "uvol-rw-$1" "uvol-wd-$1" || return $?
+               block_hotplug remove "$voldev"
                return 0
        fi
 }
@@ -169,6 +188,7 @@ updatevol() {
        [ "$2" ] || return 22
        vol_is_mode "$voldev" wo || return 22
        ubiupdatevol -s "$2" "/dev/$voldev" -
+       uvol_uci_add "$1" "/dev/$voldev" "ro"
        ubirename "/dev/$ubidev" "uvol-wo-$1" "uvol-rd-$1"
 }
 
@@ -199,7 +219,7 @@ bootvols() {
                case "$volname" in
                        uvol-ro-*)
                                voldev="/dev/ubiblock${voldev:3}"
-                               ubiblock --create "/dev/$voldev"
+                               ubiblock --create "/dev/$voldev" || return $?
                                ;;
                        *)
                                continue
index 9eae278c8d0ad2a7f62fc700b22187215c9e3a67..87fc2432b27f0c67b21f3d708b5dbb0f46f8bda4 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=yara
-PKG_VERSION:=4.0.5
+PKG_VERSION:=4.1.1
 PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/VirusTotal/yara/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=ea7ebefad05831faf6f780cab721611b0135803f03a84c27eeba7bfe0afc3aae
+PKG_HASH:=5f85c69606fad5cdb42e8f8101c96f6962a4928667395d9471e5aaea961e9b1d
 
 PKG_MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>
 PKG_LICENSE:=BSD-3-Clause
diff --git a/utils/yara/patches/010-openssl.patch b/utils/yara/patches/010-openssl.patch
deleted file mode 100644 (file)
index a54b000..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
---- a/libyara/include/yara/pe_utils.h
-+++ b/libyara/include/yara/pe_utils.h
-@@ -102,7 +102,7 @@ char *ord_lookup(
- #if HAVE_LIBCRYPTO
- #include <openssl/asn1.h>
--time_t ASN1_get_time_t(ASN1_TIME* time);
-+time_t ASN1_get_time_t(const ASN1_TIME* time);
- #endif
- #endif
---- a/libyara/modules/pe/pe.c
-+++ b/libyara/modules/pe/pe.c
-@@ -44,8 +44,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
- #endif
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
--#define X509_getm_notBefore X509_get_notBefore
--#define X509_getm_notAfter X509_get_notAfter
-+#define X509_get0_notBefore X509_get_notBefore
-+#define X509_get0_notAfter X509_get_notAfter
- #endif
- #endif
-@@ -1433,10 +1433,10 @@ void _parse_pkcs7(
-       }
-     }
--    date_time = ASN1_get_time_t(X509_get_notBefore(cert));
-+    date_time = ASN1_get_time_t(X509_get0_notBefore(cert));
-     set_integer(date_time, pe->object, "signatures[%i].not_before", *counter);
--    date_time = ASN1_get_time_t(X509_get_notAfter(cert));
-+    date_time = ASN1_get_time_t(X509_get0_notAfter(cert));
-     set_integer(date_time, pe->object, "signatures[%i].not_after", *counter);
-     (*counter)++;
---- a/libyara/modules/pe/pe_utils.c
-+++ b/libyara/modules/pe/pe_utils.c
-@@ -307,7 +307,7 @@ time_t timegm(
- // and cleaned up. Also uses timegm(3) instead of mktime(3).
- time_t ASN1_get_time_t(
--      ASN1_TIME* time)
-+      const ASN1_TIME* time)
- {
-   struct tm t;
-   const char* str = (const char*) time->data;
index 067fa888b9e0dab5641a68f3d0684acc52631e32..ceb26399bf3bee9c5e1624c1f013721c106d210d 100644 (file)
@@ -1,12 +1,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=yq
-PKG_VERSION:=4.11.0
+PKG_VERSION:=4.11.2
 PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/mikefarah/yq/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=0201719fcdce5e98f7620e854825fb3e81d16abf6108df424dcb00de33b26c21
+PKG_HASH:=910f64ceceabed5f63550a29923c158612be94f2855b0d10fdb549d8ad826a5f
 
 PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
 PKG_LICENSE:=MIT