Skip to content

Commit 0eaf9a9

Browse files
committed
v0.3 - made the script a bit more reliable
1 parent 6b9dc27 commit 0eaf9a9

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Version history
77

88
- 0.1 - Initial release
99
- 0.2 - Added automatic IP detection
10+
- 0.3 - Make setup.sh a bit more reliable
1011

1112

1213
Description

setup.sh

+42-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
#!/bin/bash
2-
localip=`/sbin/ifconfig en0 |grep 'inet ' |xargs -L1 |cut -d ' ' -f2`
2+
if [ "$1" == "-i" ] ; then
3+
if [ "$2" == "" ] ; then
4+
echo "-i needs a parameter, eg: -i en0"
5+
exit 1
6+
fi
7+
wifi_interface="$2"
8+
else
9+
wifi_interface=`/usr/sbin/networksetup -listallhardwareports |grep -A1 -i 'Wi-Fi' |tail -n1 |cut -d ' ' -f2`
10+
fi
311

4-
echo "Waiting for iDevice..."
5-
while :
6-
do
7-
deviceip=`ping -c16 -t2 169.254.255.255 2>/dev/null |grep 'bytes from' |grep -v "$localip" |tail -n1 |cut -d ' ' -f4 |cut -d ':' -f1`
12+
if [ "$wifi_interface" == "" ] ; then
13+
echo
14+
echo "Unable to detect your wifi interface."
15+
echo
16+
echo "You can specify it manually with -i, eg:"
17+
echo
18+
echo "$0 -i en0"
19+
echo
20+
exit 1
21+
fi
822

9-
if [ "$deviceip" != "" ] ; then
10-
break
11-
fi
23+
checkif=`/sbin/ifconfig "$wifi_interface" 2>/dev/null`
24+
25+
if [ "$checkif" == "" ] ; then
26+
echo "interface $wifi_interface does not exist"
27+
exit 1
28+
fi
29+
30+
echo -n "Waiting for local self-assign IP... "
31+
32+
while [ "$localip" == "" ] ; do
33+
localip=`/sbin/ifconfig $wifi_interface |grep 'inet ' |xargs -L1 |cut -d ' ' -f2`
34+
sleep 1
1235
done
1336

37+
echo "$localip"
38+
39+
echo -n "Waiting for iDevice... "
40+
41+
while [ "$deviceip" == "" ] ; do
42+
deviceip=`ping -c16 -t2 169.254.255.255 2>/dev/null |grep 'bytes from' |grep -v "$localip" |tail -n1 |cut -d ' ' -f4 |cut -d ':' -f1`
43+
sleep 1
44+
done
45+
46+
echo "$deviceip"
47+
1448
killall Proxifier 1>/dev/null 2>/dev/null
1549
sleep 2
1650
cp proxifier.template ~/Library/Application\ Support/Proxifier/Profiles/default.ppx

0 commit comments

Comments
 (0)