@nikolal Untested, rudimentary, invokes external software (curl, s-nail and gpg), possibly not compatible with PGP emails expected by existing software… but I think this should work:
#!/usr/bin/env python2
import os, sys
def changed(new_ip, recipient):
with open("ip", "w") as f:
f.write(new_ip)
os.system("gpg --trust-model=always -ea -r " + recipient + " - < ip | mail -s ip_has_changed " + recipient)
try:
with open("recipient") as f:
recipient = f.read()
except Exception:
print('could not read recipient')
sys.exit(1)
try:
with open("ip") as f:
old_ip = f.read()
except Exception:
old_ip = None
new_ip = os.popen("curl ipconfig.sh").read()
if old_ip != new_ip:
changed(new_ip, recipient)
Configure with echo -n some@email.address > recipient.
Pardon any typos. Probably usable in cron.