Skip to content

Commit d4f33fa

Browse files
committed
Make internalip sh compatible
1 parent 7b40be0 commit d4f33fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internalip

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# get internal IP address
44
# used for outgoing Internet connections
@@ -7,10 +7,13 @@
77
resolve() {
88
(gethostip -d $1 || getent ahostsv4 $t | grep RAW | awk '{print $1; exit}') 2>/dev/null
99
}
10+
noip() {
11+
[ -n "$(echo $1 | tr -d '0-9.\n')" ]
12+
}
1013

1114
[ -n "$1" ] && t=$1 || t='8.8.8.8'
1215

13-
[ -n "${t//[0-9.]}" ] && t=$(resolve $t)
16+
noip $t && t=$(resolve $t)
1417

1518
[ -n "$t" ] || { echo Cannot resolve domain $1 >&2; exit 1; }
1619

0 commit comments

Comments
 (0)