English Forums > Tutorials and FAQs

Script to send emails for updates

(1/6) > >>

bartjsmit:
This script follows on from the example in the 'Using the API Howto' wiki entry. https://wiki.opnsense.org/index.php/Howto_use_the_API

Replace the redacted api_key and api_secret strings with your own and set the URL of your OPNsense instance as well as your name/email address.

It requires an MTA (set to localhost in the script) and can be run from cron. Tested with Python 2.7.5-34 on CentOS 7.

franco:
Hi there,

This is really cool, thanks for sharing. I'm making this sticky in the general forum. :)


Cheers,
Franco

philamonster:
Thanks for this. Confirmed on Debian wheezy. Got an update email today for 16.1.

franco:
"Dude, where's my 16.1?"

bartjsmit:
As some of you will have noticed, there is an issue with the script versus the Python request library, or rather with my (lack of) understanding of the latter.

Whereas before all JSON elements were returned as (unicode) list, some are now dict variables, causing the script to bomb out on a type error.

Attached is version 1.1 of fw_update.py, that tests for the returned type. As before, you can un-redact it and run it from cron.

Tested with Python 2.7.5-34 and python-requests-2.6.0-1 on CentOS 7

Enjoy!

Bart...

Navigation

[0] Message Index

[#] Next page

Go to full version