From 6d2fd44dba82d3c24cbe9643bf4a884dfed99ceb Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Mon, 13 Apr 2026 16:35:39 +0200 Subject: [PATCH] - Start migration of dns, network & vpn lib, - Start migration of rx3_net_adm. --- ReleaseNotes.txt | 10 +++--- usr/{local => }/lib/default.bash | 0 usr/{local => }/lib/dns.bash | 36 ++++++++++++++----- usr/{local => }/lib/network.bash | 39 ++++++++++++++++---- usr/{local => }/lib/vpn.bash | 31 ++++++++++++++-- usr/{local => }/sbin/cert_dump | 0 usr/{local => }/sbin/ip_host_update | 0 usr/{local => }/sbin/ns-launch | 0 usr/{local => }/sbin/openvpn-client-down | 0 usr/{local => }/sbin/openvpn-client-up | 0 usr/{local => }/sbin/openvpn-down | 0 usr/{local => }/sbin/openvpn-status | 0 usr/{local => }/sbin/openvpn-up | 0 usr/{local => }/sbin/rx3_net_adm | 46 ++++++++++++++++++++---- usr/{local => }/sbin/rx3_vpn_adm | 0 15 files changed, 132 insertions(+), 30 deletions(-) rename usr/{local => }/lib/default.bash (100%) rename usr/{local => }/lib/dns.bash (81%) rename usr/{local => }/lib/network.bash (96%) rename usr/{local => }/lib/vpn.bash (90%) rename usr/{local => }/sbin/cert_dump (100%) rename usr/{local => }/sbin/ip_host_update (100%) rename usr/{local => }/sbin/ns-launch (100%) rename usr/{local => }/sbin/openvpn-client-down (100%) rename usr/{local => }/sbin/openvpn-client-up (100%) rename usr/{local => }/sbin/openvpn-down (100%) rename usr/{local => }/sbin/openvpn-status (100%) rename usr/{local => }/sbin/openvpn-up (100%) rename usr/{local => }/sbin/rx3_net_adm (70%) rename usr/{local => }/sbin/rx3_vpn_adm (100%) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 601e060..89ef0c1 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,11 +1,11 @@ ------------------------------------------------------------------------------------------------------------------------------------ -Network Tools V 1.1.4 - A. GIBERT - 2026/04/13 +Network Tools V 1.2.0 - A. GIBERT - 2026/04/xx ------------------------------------------------------------------------------------------------------------------------------------ -- Add rx3-network.minotaur config file, -- Add missing etc/sudoers.d/rx3-network config file, -- Minor config files update, -- Last release of the 1.1.x branch. +- Migrate Network Tools to the new Rx3 Base Bash library, +- Add RPM Spec & bash completion files, +- Move install dir form /usr/locla to usr, +- Support now rx3-base 1.1.1. diff --git a/usr/local/lib/default.bash b/usr/lib/default.bash similarity index 100% rename from usr/local/lib/default.bash rename to usr/lib/default.bash diff --git a/usr/local/lib/dns.bash b/usr/lib/dns.bash similarity index 81% rename from usr/local/lib/dns.bash rename to usr/lib/dns.bash index 0e67f29..d2e84b5 100644 --- a/usr/local/lib/dns.bash +++ b/usr/lib/dns.bash @@ -1,28 +1,48 @@ #!/bin/bash +#----------------------------------------------------------------------------------------------------------------------------------- +# +# Rx3 DNS Library +# +# Copyright (C) 2025-2026 Arnaud G. GIBERT +# mailto:arnaud@rx3.net +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . +# +#----------------------------------------------------------------------------------------------------------------------------------- -if [[ "${DNS_BASH}" != "" ]] +if [[ "${RX3_DNS_LIB}" != "" ]] then return else - declare -g DNS_BASH=1 + declare -g RX3_DNS_LIB=1 fi +#----------------------------------------------------------------------------------------------------------------------------------- # Includes #----------------------------------------------------------------------------------------------------------------------------------- -if [[ -e /usr/local/lib/default.bash ]] -then - . /usr/local/lib/default.bash -else - . /usr/global/lib/default.bash -fi +: "${RX3_LIB_DIR:=/usr/lib/rx3}" +. "${RX3_LIB_DIR}/base.bash" +#----------------------------------------------------------------------------------------------------------------------------------- # Global Variable #----------------------------------------------------------------------------------------------------------------------------------- diff --git a/usr/local/lib/network.bash b/usr/lib/network.bash similarity index 96% rename from usr/local/lib/network.bash rename to usr/lib/network.bash index ecfaed2..a2da43a 100644 --- a/usr/local/lib/network.bash +++ b/usr/lib/network.bash @@ -1,23 +1,48 @@ #!/bin/bash +#----------------------------------------------------------------------------------------------------------------------------------- +# +# Rx3 Network Library +# +# Copyright (C) 2025-2026 Arnaud G. GIBERT +# mailto:arnaud@rx3.net +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . +# +#----------------------------------------------------------------------------------------------------------------------------------- -if [[ "${NETWORK_BASH}" != "" ]] +if [[ "${RX3_NETWORK_LIB}" != "" ]] then return else - declare -g NETWORK_BASH=1 + declare -g RX3_NETWORK_LIB=1 fi +#----------------------------------------------------------------------------------------------------------------------------------- # Includes #----------------------------------------------------------------------------------------------------------------------------------- -. /usr/local/lib/dns.bash +: "${RX3_LIB_DIR:=/usr/lib/rx3}" +. "${RX3_LIB_DIR}/dns.bash" +#----------------------------------------------------------------------------------------------------------------------------------- # Global Variable #----------------------------------------------------------------------------------------------------------------------------------- @@ -119,7 +144,7 @@ num_to_ip() # Optional safety check if (( num < 0 || num > 4294967295 )) then - echo "num_to_ip: value out of range (0‑4294967295)" >&2 + echo_error "num_to_ip: value out of range (0‑4294967295)" return 1 fi @@ -699,7 +724,7 @@ network_src_tab_load() if [[ " ${NETWORK_TABLE_LIST} " != *" ${nstl_table} "* ]] then - err_echo "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!" + echo_error "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!" exit 1 fi @@ -1094,13 +1119,13 @@ network_table_set() if [[ "${src_id}" == "" ]] then - err_echo "IP not found: [${nts_ip}]!" + echo_error "IP not found: [${nts_ip}]!" return 1 fi if [[ " ${NETWORK_TABLE_LIST} " != *" ${nts_table} "* ]] then - err_echo "Table not found: [${nts_table}]!" + echo_error "Table not found: [${nts_table}]!" return 1 fi diff --git a/usr/local/lib/vpn.bash b/usr/lib/vpn.bash similarity index 90% rename from usr/local/lib/vpn.bash rename to usr/lib/vpn.bash index 6ce1dde..0d45d61 100644 --- a/usr/local/lib/vpn.bash +++ b/usr/lib/vpn.bash @@ -1,23 +1,48 @@ #!/bin/bash +#----------------------------------------------------------------------------------------------------------------------------------- +# +# Rx3 VPN Library +# +# Copyright (C) 2025-2026 Arnaud G. GIBERT +# mailto:arnaud@rx3.net +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . +# +#----------------------------------------------------------------------------------------------------------------------------------- -if [[ "${VPN_BASH}" != "" ]] +if [[ "${RX3_VPN_LIB}" != "" ]] then return else - declare -g VPN_BASH=1 + declare -g RX3_VPN_LIB=1 fi +#----------------------------------------------------------------------------------------------------------------------------------- # Includes #----------------------------------------------------------------------------------------------------------------------------------- -. /usr/local/lib/network.bash +: "${RX3_LIB_DIR:=/usr/lib/rx3}" +. "${RX3_LIB_DIR}/network.bash" +#----------------------------------------------------------------------------------------------------------------------------------- # Global Variable #----------------------------------------------------------------------------------------------------------------------------------- diff --git a/usr/local/sbin/cert_dump b/usr/sbin/cert_dump similarity index 100% rename from usr/local/sbin/cert_dump rename to usr/sbin/cert_dump diff --git a/usr/local/sbin/ip_host_update b/usr/sbin/ip_host_update similarity index 100% rename from usr/local/sbin/ip_host_update rename to usr/sbin/ip_host_update diff --git a/usr/local/sbin/ns-launch b/usr/sbin/ns-launch similarity index 100% rename from usr/local/sbin/ns-launch rename to usr/sbin/ns-launch diff --git a/usr/local/sbin/openvpn-client-down b/usr/sbin/openvpn-client-down similarity index 100% rename from usr/local/sbin/openvpn-client-down rename to usr/sbin/openvpn-client-down diff --git a/usr/local/sbin/openvpn-client-up b/usr/sbin/openvpn-client-up similarity index 100% rename from usr/local/sbin/openvpn-client-up rename to usr/sbin/openvpn-client-up diff --git a/usr/local/sbin/openvpn-down b/usr/sbin/openvpn-down similarity index 100% rename from usr/local/sbin/openvpn-down rename to usr/sbin/openvpn-down diff --git a/usr/local/sbin/openvpn-status b/usr/sbin/openvpn-status similarity index 100% rename from usr/local/sbin/openvpn-status rename to usr/sbin/openvpn-status diff --git a/usr/local/sbin/openvpn-up b/usr/sbin/openvpn-up similarity index 100% rename from usr/local/sbin/openvpn-up rename to usr/sbin/openvpn-up diff --git a/usr/local/sbin/rx3_net_adm b/usr/sbin/rx3_net_adm similarity index 70% rename from usr/local/sbin/rx3_net_adm rename to usr/sbin/rx3_net_adm index c55e5c9..6ccef0b 100755 --- a/usr/local/sbin/rx3_net_adm +++ b/usr/sbin/rx3_net_adm @@ -1,4 +1,43 @@ #!/bin/bash +#----------------------------------------------------------------------------------------------------------------------------------- +# +# Rx3 Net Adm +# +# Copyright (C) 2025-2026 Arnaud G. GIBERT +# mailto:arnaud@rx3.net +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . +# +#----------------------------------------------------------------------------------------------------------------------------------- + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Includes +#----------------------------------------------------------------------------------------------------------------------------------- + +: "${RX3_LIB_DIR:=/usr/lib/rx3}" +. "${RX3_LIB_DIR}/network.bash" + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Global Variable +#----------------------------------------------------------------------------------------------------------------------------------- RETVAL=0 prog="rx3-net" @@ -12,13 +51,6 @@ prog="rx3-net" -# Includes -#----------------------------------------------------------------------------------------------------------------------------------- - -. /usr/local/lib/network.bash - - - #-------------------------------------------------------------------------------------------------------------------------- diff --git a/usr/local/sbin/rx3_vpn_adm b/usr/sbin/rx3_vpn_adm similarity index 100% rename from usr/local/sbin/rx3_vpn_adm rename to usr/sbin/rx3_vpn_adm