mvo5 / unattended-upgrades

Automatic installation of security upgrades on apt based systems
GNU General Public License v2.0
285 stars 77 forks source link

u-u: implement plugin system with `postrun()` functionality #355

Closed mvo5 closed 8 months ago

mvo5 commented 8 months ago

[opening as draft, this needs a bit more work, I think the right way is to add a namedtuple or a dataclass for class UnattendedUpgradeResult

This commit implements a new plugin system. Plugins are python classes that start with UnattendedUpgradesPlugin and that are locates in one of the following directories:

/etc/unattended-upgrades/plugins/
/usr/share/unattended-upgrades/plugins

Plugins are also searched in the UNATTENDED_UPGRADES_PLUGIN_PATH environment path and in any of the directories in the apt configration: Unattended-Upgrade::Dirs::Plugins::.

The postrun() function is called with a single python dictionary as the argument. This dictionary contains the following elements:

This new code can be tested with:

$ sudo PYTHONPATH=. UNATTENDED_UPGRADES_PLUGIN_PATH=./examples/plugins/ ./unattended-upgrade
papamoose commented 8 months ago

After changing some keys in my apprise plugin this still seems to work as expected. I've deployed this PR where I'm able for testing.

mvo5 commented 8 months ago

After changing some keys in my apprise plugin this still seems to work as expected. I've deployed this PR where I'm able for testing.

Thanks for the testing and sorry for these slightly incompatibilities in this final version, once this is merged/released that will (obviously) not change again :)

mvo5 commented 8 months ago

I tweaked the documentation for the new feature a little bit and I think it's ready now . If someone could double check for clarity/spelling/typos that would be appreciated! I want to merge this soon(ish).

papamoose commented 8 months ago

After changing some keys in my apprise plugin this still seems to work as expected. I've deployed this PR where I'm able for testing.

Looks good so far. All systems are reporting in as they should.