* set curl timeout for fetching ip-address to non fractional number, because on some systems catching error about max-time option as "expected a proper numerical parameter"
* use regex for update ip
This commit is contained in:
@ -5,7 +5,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
print_ip_address() {
|
print_ip_address() {
|
||||||
local ip_address=$(curl --max-time 1.5 --silent http://ip.me)
|
local ip_address=$(curl --max-time 2 --silent http://ip.me)
|
||||||
echo ${ip_address}
|
echo ${ip_address}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
ip_address="$($CURRENT_DIR/ip_address.sh)"
|
ip_address="$($CURRENT_DIR/ip_address.sh)"
|
||||||
ip_address_interpolation_string="\#{ip_address}"
|
|
||||||
|
|
||||||
do_interpolation() {
|
do_interpolation() {
|
||||||
local string="$1"
|
local string="$1"
|
||||||
@ -15,7 +14,7 @@ do_interpolation() {
|
|||||||
ip_addr="Offline"
|
ip_addr="Offline"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local interpolated="$(echo $1 | sed "s/$ip_address_interpolation_string/$ip_addr/g")"
|
local interpolated="$(echo $1 | sed "s/\(Offline\|[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\)/$ip_addr/g")"
|
||||||
|
|
||||||
echo "$interpolated"
|
echo "$interpolated"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user