Compare commits
4 Commits
11_0_0-8_e
...
95eba03095
Author | SHA1 | Date | |
---|---|---|---|
95eba03095 | |||
f12ac8900e | |||
d3486008d1 | |||
97d1058b70 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
*.log
|
*.log
|
||||||
*spec-20*
|
*spec-20*
|
||||||
*.tar.xz
|
*.tar.xz
|
||||||
|
*.bak
|
||||||
|
54
root/sbin/e-smith/getmyip
Normal file
54
root/sbin/e-smith/getmyip
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# List of services to query for the public IP
|
||||||
|
services=(
|
||||||
|
"ifconfig.me"
|
||||||
|
"ipinfo.io/ip"
|
||||||
|
"icanhazip.com"
|
||||||
|
"api.ipify.org"
|
||||||
|
"ident.me"
|
||||||
|
"ip.tyk.nu"
|
||||||
|
"checkip.amazonaws.com"
|
||||||
|
"ipecho.net/plain"
|
||||||
|
"myip.dnsomatic.com"
|
||||||
|
"ip.seeip.org"
|
||||||
|
"ipapi.co/ip"
|
||||||
|
"wtfismyip.com/text"
|
||||||
|
"openident.net/ip"
|
||||||
|
"ifconfig.co/ip"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Function to shuffle the array of services
|
||||||
|
shuffle_services() {
|
||||||
|
local i
|
||||||
|
for ((i=${#services[@]} - 1; i > 0; i--)); do
|
||||||
|
local j=$((RANDOM % (i + 1)))
|
||||||
|
local temp="${services[i]}"
|
||||||
|
services[i]="${services[j]}"
|
||||||
|
services[j]="$temp"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to fetch the public IP address
|
||||||
|
get_public_ip() {
|
||||||
|
shuffle_services
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
public_ip=$(curl -s --max-time 5 "$service")
|
||||||
|
|
||||||
|
# Check if the curl request was successful and there's a valid IP address
|
||||||
|
if [[ $? -eq 0 && $public_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
logger -t public_ip_script "Service used: $service, IP found: $public_ip"
|
||||||
|
echo "$public_ip"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If none of the services returned a valid IP, output an error message
|
||||||
|
echo "Failed to retrieve public IP using all services." >&2
|
||||||
|
logger -t public_ip_script "Error: Failed to retrieve public IP using all services."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute the function
|
||||||
|
get_public_ip
|
||||||
|
|
@@ -6,7 +6,7 @@ Summary: smeserver server and gateway - library module
|
|||||||
%define name smeserver-lib
|
%define name smeserver-lib
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
%define version 11.0.0
|
%define version 11.0.0
|
||||||
%define release 8
|
%define release 9
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: %{release}%{?dist}
|
Release: %{release}%{?dist}
|
||||||
License: Artistic
|
License: Artistic
|
||||||
@@ -33,6 +33,9 @@ Provides: e-smith-lib
|
|||||||
smeserver server and gateway software - library module.
|
smeserver server and gateway software - library module.
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Dec 12 2024 Brian Read <brianr@koozali.org> 11.0.0-9.sme
|
||||||
|
- add in getmyip [SME: 12810 ]
|
||||||
|
|
||||||
* Tue Nov 12 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
|
* Tue Nov 12 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
|
||||||
- fix Use of uninitialized value [SME: 12760]
|
- fix Use of uninitialized value [SME: 12760]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user