-
Notifications
You must be signed in to change notification settings - Fork 0
/
getip
executable file
·38 lines (38 loc) · 979 Bytes
/
getip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
cd `dirname $0`/info
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 ip.3322.net`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 ifconfig.me`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 ident.me`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 icanhazip.com`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 ipecho.net/plain`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 whatismyip.akamai.com`
fi
if [ "$curr_ip" = "" ]; then
curr_ip=`curl -m 10 myip.dnsomatic.com`
fi
git fetch >> /dev/null 2>&1
git reset FETCH_HEAD --hard >> /dev/null 2>&1
last_ip=`cat ip.ini`
if [ "$curr_ip" = "" -o "$curr_ip" = "$last_ip" ]; then
:
else
host_name=`hostname`
version=`date "+%Y/%m/%d %H:%M:%S"`
git branch "$host_name" >> /dev/null 2>&1
git checkout "$host_name" >> /dev/null 2>&1
echo $curr_ip > ip.ini
git add .
git commit -m "$version" --amend
git push -u origin "$host_name" -f
fi