diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index 4b40b7c..90f1dab 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -1,3 +1,12 @@
+------------------------------------------------------------------------------------------------------------------------------------
+MyIP V 1.2.1 - A. GIBERT - 2026/04/22
+------------------------------------------------------------------------------------------------------------------------------------
+
+- Migrate to Rx3 base libray 1.1.2,
+- Add bash completion script.
+
+
+
------------------------------------------------------------------------------------------------------------------------------------
MyIP V 1.2.0 - A. GIBERT - 2025/09/18
------------------------------------------------------------------------------------------------------------------------------------
diff --git a/SPECS/myip.spec b/SPECS/myip.spec
index 93397a4..2607769 100644
--- a/SPECS/myip.spec
+++ b/SPECS/myip.spec
@@ -1,5 +1,30 @@
+#-----------------------------------------------------------------------------------------------------------------------------------
+#
+# MyIP
+#
+# 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
+# .
+#
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+
+
%define name myip
-%define version 1.2.0
+%define version 1.2.1
%define release %mkrel 1rx3
%global debug_package %{nil}
@@ -14,15 +39,17 @@ Version: %{version}
Release: %{release}
Summary: Simple script to get your public and private IP addresses
License: GPL
-URL: https://git.rx3.org/gitea/rx3/myip
+URL: https://git.rx3.org/gitea/rx3/%{name}
-Source0: %{name}-%{version}.tar.bz2
+Source0: https://git.rx3.org/gitea/rx3/%{name}/archive/%{name}-%{version}.tar.gz
Distribution: Rx3 Free Software
Vendor: Rx3
Packager: Arnaud G. GIBERT
-Requires: bind-utils
+BuildArch: noarch
+
+Requires: network_tools-libs
@@ -31,34 +58,74 @@ Simple script to get your public and private IP.
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Prep
+#-----------------------------------------------------------------------------------------------------------------------------------
+
%prep
%setup -q -n %{name}
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Build
+#-----------------------------------------------------------------------------------------------------------------------------------
+
%build
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Install
+#-----------------------------------------------------------------------------------------------------------------------------------
+
%install
-install -D -pm 755 bin/%{name} %{buildroot}%{_bindir}/%{name}
-install -D -pm 755 var/www/cgi-bin/%{name}.cgi %{buildroot}%{_webcgi}/%{name}.cgi
+install -D -pm 644 etc/bash_completion.d/%{name} %{buildroot}%{_sysconfdir}/bash_completion.d/%{name}
+install -D -pm 755 bin/%{name} %{buildroot}%{_bindir}/%{name}
+install -D -pm 755 www/cgi-bin/%{name}.cgi %{buildroot}%{_webcgi}/%{name}.cgi
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Check
+#-----------------------------------------------------------------------------------------------------------------------------------
+
%check
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Files
+#-----------------------------------------------------------------------------------------------------------------------------------
+
%files
-%doc ReadMe.txt ReleaseNotes.txt
+%doc ReadMe.txt ReleaseNotes.txt ToDo.txt
%license GNU_GPL-3.0.txt GNU_LGPL-3.0.txt GNU_FDL-1.3.txt
+%{_sysconfdir}/bash_completion.d/%{name}
%{_bindir}/%{name}
%{_webcgi}/%{name}.cgi
-%changelog
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# ChangeLog
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+%%changelog
+* Tue Apr 21 2026 Arnaud G. GIBERT - 1.2.1-1rx3.mga9
+- Update to 1.2.1
+- Add bash completion script
+
* Thu Sep 18 2025 Arnaud G. GIBERT - 1.2.0-1rx3.mga9
- Update to 1.2.0
diff --git a/ToDo.txt b/ToDo.txt
new file mode 100644
index 0000000..e8bfc71
--- /dev/null
+++ b/ToDo.txt
@@ -0,0 +1 @@
+- ...
diff --git a/bin/myip b/bin/myip
index 200e931..3231e0c 100755
--- a/bin/myip
+++ b/bin/myip
@@ -1,144 +1,246 @@
#!/bin/bash
-#-----------------------------------------------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------------------------------------------------------------
#
# MyIP
-# Copyright (C) 2025 Arnaud G. GIBERT
+#
+# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or any later version.
+#
+# 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 General Public License for more details.
+# 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 General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; If not, see
+# .
#
-#-----------------------------------------------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------------------------------------------------------------
-WEB_SERVER_NAME="www.rx3"
- WEB_SERVER_IP="10.0.0.65"
-RESOLVER_NAME="resolver1.opendns.com"
- RESOLVER_IP="208.67.222.222"
-declare -g RESOLV_STATUS="OK"
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Includes
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+: "${RX3_LIB_DIR:=/usr/lib/rx3}"
+. "${RX3_LIB_DIR}/network.bash"
-#-----------------------------------------------------------------------------------------------------------------------
-# ip_filter
-#-----------------------------------------------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Global Variables
+#-----------------------------------------------------------------------------------------------------------------------------------
-ip_filter()
+declare -g VERSION="1.2.1"
+declare -g NAME="MyIP"
+declare -g HELP="usage: [-h | --help] | [-V | --version] | [-i | --internal] | [-a | --all] [-T | --test] [-v | --verbose] "
+
+declare -g MODE="EXTERNAL"
+declare -g VERBOSE="FALSE"
+declare -g DRY_RUN="FALSE"
+declare -g RETVAL=0
+
+declare -g WEB_SERVER_NAME="www.rx3"
+declare -g WEB_SERVER_IP="10.0.0.65"
+declare -g WEB_SERVER_URL="http://www.rx3/cgi-bin/myip.cgi"
+
+declare -g RESOLVER_NAME="resolver1.opendns.com"
+declare -g RESOLVER_IP="208.67.222.222"
+
+
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Version Print
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+myip_version_print()
{
- grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
+ version_print
}
-#-----------------------------------------------------------------------------------------------------------------------
-# resolv
-#-----------------------------------------------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Help Print
+#-----------------------------------------------------------------------------------------------------------------------------------
-resolv()
+myip_help_print()
{
- local host_name="$1"
- local host_ip="$2"
+ myip_version_print
+ help_print
+ echo " default: external IP"
+ echo " -i: internal IP"
+ echo " -a: internal + external IP"
+}
+
+
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Arg Parse
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+myip_args_parse()
+{
+ tmp_args=$(getopt -o ahiTvV --long all,help,internal,test,verbose,version -n "${NAME}" -- "$@")
+
+ if [ $? != 0 ]; then echo_error "Terminating..."; exit 1; fi
+
+ eval set -- "${tmp_args}"
+
+ while true
+ do
+ case "$1" in
+ # Mode switches
+ -a|--all) MODE="ALL"; shift;;
+ -h|--help) MODE="EXIT"; myip_help_print; shift;;
+ -i|--internal) MODE="INTERNAL"; shift;;
+ -V|--version) MODE="EXIT"; myip_version_print; shift;;
+
+ # Global options
+ -T|--test) DRY_RUN="TRUE"; shift;;
+ -v|--verbose) VERBOSE="TRUE"; shift;;
+
+ # End of options
+ --) shift; break;;
+ *) echo "args_parse internal error [$1]!"; exit 1;;
+ esac
+ done
+}
+
+
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Internal IP Get
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+myip_internal_get()
+{
+ local int_ip
+ local int_label
+ local web_server_ip
- resolv_ip="$( dig +short "${host_name}" | ip_filter)"
-
- if [[ "${resolv_ip}" == "" ]]
+ if [[ "${VERBOSE}" == "TRUE" ]]
then
- RESOLV_STATUS="KO"
- resolv_ip="${host_ip=}"
+ int_label="Internal IP: "
else
- RESOLV_STATUS="OK"
+ int_label=""
fi
-}
+
+ dns_lookup "A" "${WEB_SERVER_NAME}" "NOCACHE"
+ web_server_ip="${dns_value}"
-
-
-
-#-----------------------------------------------------------------------------------------------------------------------
-# main
-#-----------------------------------------------------------------------------------------------------------------------
-
-if [[ "$1" == "-h" ]]
-then
- echo "myip [-i] | [-a] | [-h]"
- echo "default: external IP"
- echo " -i: internal IP"
- echo " -a: internal + external IP"
-else
- if [[ "$1" == "-a" ]]
+ if [[ "${web_server_ip}" == "" ]]
then
- int_flag="TRUE"
- ext_flag="TRUE"
- verbose_flag="TRUE"
- else
- verbose_flag="FALSE"
-
- if [[ "$1" == "-i" ]]
+ if [[ "${VERBOSE}" == "TRUE" ]]
then
- int_flag="TRUE"
- ext_flag="FALSE"
- else
- int_flag="FALSE"
- ext_flag="TRUE"
+ echo_error "Warning: resolver failed for [${WEB_SERVER_NAME}], using default address: [${WEB_SERVER_IP}]"
fi
+
+ web_server_ip="${WEB_SERVER_IP}"
fi
-fi
+ int_ip="$(cmd_exec curl --resolve "${WEB_SERVER_NAME}:80:${web_server_ip}" -s "${WEB_SERVER_URL}" | ip_ip_filter)"
-
-if [[ ${verbose_flag} == "TRUE" ]]
-then
- int_label="Internal IP: "
- ext_label="External IP: "
-else
- int_label=""
- ext_label=""
-fi
-
-
-if [[ ${int_flag} == "TRUE" ]]
-then
- resolv "${WEB_SERVER_NAME}" "${WEB_SERVER_IP}"
- web_server_ip="${resolv_ip}"
-
- int_ip="$( curl --resolve ${WEB_SERVER_NAME}:80:${web_server_ip} -s http://www.rx3/cgi-bin/myip.cgi | ip_filter)"
-
- if [[ ( "${int_label}" != "") && ( "${RESOLV_STATUS}" != "OK") ]]
- then
- echo "Warning: resolver failed for [${WEB_SERVER_NAME}], using default address: [${WEB_SERVER_IP}]"
- fi
-
echo "${int_label}${int_ip}"
-fi
+}
+
+
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# External IP Get
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+myip_external_get()
+{
+ local ext_ip
+ local ext_label
+ local resolver_ip
-if [[ ${ext_flag} == "TRUE" ]]
-then
- resolv "${RESOLVER_NAME}" "${RESOLVER_IP}"
- resolver_ip="${resolv_ip}"
- ext_ip="$( dig +short myip.opendns.com @${resolver_ip} | ip_filter)"
-
- if [[ ( "${ext_label}" != "") && ( "${RESOLV_STATUS}" != "OK") ]]
+ if [[ "${VERBOSE}" == "TRUE" ]]
then
- echo "Warning: resolver failed for [${RESOLVER_NAME}], using default address: [${RESOLVER_IP}]"
+ ext_label="External IP: "
+ else
+ ext_label=""
fi
-
+
+ dns_lookup "A" "${RESOLVER_NAME}" "NOCACHE"
+ resolver_ip="${dns_value}"
+
+ if [[ "${resolver_ip}" == "" ]]
+ then
+ if [[ "${VERBOSE}" == "TRUE" ]]
+ then
+ echo_error "Warning: resolver failed for [${RESOLVER_NAME}], using default address: [${RESOLVER_IP}]"
+ fi
+
+ resolver_ip="${RESOLVER_IP}"
+ fi
+
+ ext_ip="$(cmd_exec dig +short myip.opendns.com "@${resolver_ip}" | ip_ip_filter)"
+
echo "${ext_label}${ext_ip}"
+}
+
+
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# Main
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+myip_args_parse "$@"
+
+
+
+if [[ "${MODE}" == "EXIT" ]]
+then
+ exit 0
fi
+
+dns_init
+
+case "${MODE}" in
+ "INTERNAL")
+ myip_internal_get
+ ;;
+
+ "EXTERNAL")
+ myip_external_get
+ ;;
+
+ "ALL")
+ myip_internal_get
+ myip_external_get
+ ;;
+
+ *)
+ myip_help_print
+ RETVAL=1
+ ;;
+esac
+
+dns_deinit
+
+exit ${RETVAL}
diff --git a/etc/bash_completion.d/myip b/etc/bash_completion.d/myip
new file mode 100644
index 0000000..74dc251
--- /dev/null
+++ b/etc/bash_completion.d/myip
@@ -0,0 +1,65 @@
+#!/bin/bash
+#-----------------------------------------------------------------------------------------------------------------------------------
+#
+# MyIP Bash Completion
+#
+# 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
+# .
+#
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+
+
+#-----------------------------------------------------------------------------------------------------------------------------------
+# MyIP Completion
+#-----------------------------------------------------------------------------------------------------------------------------------
+
+_myip_completion()
+{
+ local mode_opts="-h --help -V --version -i --internal -a --all"
+ local glob_opts="-T --test -v --verbose"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+
+ local mode_set="FALSE"
+ local i
+
+ COMPREPLY=()
+
+ # Scan already provided words to detect if a mode option was given
+ for (( i=1; i