-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·44 lines (37 loc) · 1.14 KB
/
Copy pathscript.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.14 KB
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
39
40
41
42
43
44
#!/bin/bash
#Autor/Author: Rafael Roa
#Twitter:@rafarq
#github: https://github.com/rafarq
#Descripcion:
#Script para enviar un mensaje mediante PushOver con la ip externa del router cada vez que cambie.
#Description:
#Get a push notification via PushOver when your computer changes its public IP.
#CONFIGURATION
#CONFIGURACION
Path='/home/pi/'
#Se comprueba cual es la ip actual
#We check the current ip
IP=$(curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
echo La ip actual es "$IP"
#The old ip is retrieved
#Se recupera la ip anterior que está almacenada en el archivo currentIP.txt
oldIP=`cat "$Path"currentIP.txt`
echo La ip anterior era "$oldIP"
#We compare the old and the new ip
#Se comparan las dos IPs para ver si son iguales
if [ $IP = $oldIP ]
then
#there is nothing to do
#no es necesario hacer nada
echo Son iguales
else
#We send a notification
#se envía una notificación usando pushover
echo No son iguales
curl -s \
--form-string "token=yourTOKEN" \
--form-string "user=yourUSER" \
--form-string "message=la nueva IP es $IP" \
https://api.pushover.net/1/messages.json
echo "$IP" > $Path"currentIP.txt"
fi