Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow configuration of a pre-execution hook for arbitrary conditions #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ Supported Options Reference
```
The default is an empty list which means updates are applied every day.

* `Unattended-Upgrade::Special-Conditions-Script` - path to a script on which to make execution dependent

Allows the definition of arbitrary conditions for update execution.
If set, the given script is executed. If it returns 0, unattended-upgrades proceeds, otherwise it stops.

Example - apply updates only with Ethernet and AC Power connected
```
Unattended-Upgrade::Special-Conditions-Script "/home/me/scripts/check-eth-and-ac-connected.sh";
```

* `Unattended-Upgrade::SyslogEnable` - boolean (default:False)

Expand Down
6 changes: 6 additions & 0 deletions unattended-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,12 @@ def main(options, rootdir=""):
if not is_update_day():
return

specialCondScript = apt_pkg.config.find("Unattended-Upgrade::Special-Conditions-Script", "")
if specialCondScript:
if subprocess.call([specialCondScript]) != 0:
logging.info("The script configured with Unattended-Upgrade::Special-Conditions-Script didn't return 0, stopping here!")
return

# format (origin, archive), e.g. ("Ubuntu","dapper-security")
allowed_origins = get_allowed_origins()

Expand Down