-
Notifications
You must be signed in to change notification settings - Fork 0
/
gugl.sh
34 lines (29 loc) · 876 Bytes
/
gugl.sh
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
#Set email from
EMAIL_FROM='test@test.com'
EMAIL_FROM_PASS='test'
#Set email to
EMAIL_TO='test.test@test.com'
#Get IP
IP=$(curl ifconfig.me/ip)
#Get hostname
HOSTNAME=$(hostname)
#Ip2location API key
API="TTTTTTTTTTTTTT"
#Get Ip2location data
curl -s "https://api.ip2location.io/?key=$API&ip=$IP&format=json" > geolocation.json
GEOLOCATION=$(cat geolocation.json | tr { '\n' | tr , '\n' | tr } '\n')
#Send email
curl --ssl-reqd --url "smtp://smtp.test.com:587" --user "$EMAIL_FROM:$EMAIL_FROM_PASS" --mail-from $EMAIL_FROM --mail-rcpt $EMAIL_TO \
--upload-file - <<EOF
From: User geolocation <$EMAIL_FROM>
To: John Doe <$EMAIL_TO>
Subject: $HOSTNAME geolocation
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
$HOSTNAME geolocation =>
$GEOLOCATION
EOF
#Delete tracks
rm -f geolocation.json
rm -f gugl.sh