Git Product home page Git Product logo

auto-patch's Introduction

GitHub Workflow Status PyPI version

Automatically install security and other system updates

This package provides a script to call zypper to install security and other system updates. It also provides systemd unit files to automatically call that script regularly.

Since the script depends on zypper, it will probably only work for SUSE distributions (openSUSE and SLES).

System requirements

Python:

  • Python 3.6 or newer.

External programs:

Required library packages:

Optional library packages:

  • setuptools_scm

    The version number is managed using this package. All source distributions add a static text file with the version number and fall back using that if setuptools_scm is not available. So this package is only needed to build out of the plain development source tree as cloned from GitHub.

  • pytest >= 3.0

    Only needed to run the test suite.

  • distutils-pytest

    Only needed to run the test suite.

Copyright and License

Copyright 2020โ€“2022 Rolf Krahl

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

auto-patch's People

Contributors

rkrahl avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

auto-patch's Issues

Add a configuration file

There are several things that need configuration in the script:

  • mail configuration: mail host, from, to,
  • control of retrying if the ZYPP library is locked, added in #4: lock_max_tries and lock_wait,
  • logging configuration, added in #5.

All of this is currently hard coded in the script, but should be made configurable in a configuration file.

Improved handling of error return codes from the zypper call

#1 and #4 improved handling of return codes from zypper for two special cases. Yet there are still several error conditions from zypper left to be dealt with. In most cases the proper reaction will probably be just throwing an error, which is what also happens now. But the return codes from zypper should at least translated into an intelligible error message.

zypper already running

Thought you might want to see this. If zypper is already running, you will get exit 7 from it.
Was thinking a wait loop to attempt might get around that.

server6:/opt/auto-patch # /usr/sbin/auto-patch.py
Traceback (most recent call last):
File "/usr/sbin/auto-patch.py", line 88, in
if patch(stdout=tmpf):
File "/usr/sbin/auto-patch.py", line 67, in patch
if Zypper.patch_check(stdout=stdout) == 0:
File "/usr/sbin/auto-patch.py", line 41, in patch_check
return cls.call(args, stdout=stdout, retcodes={100, 101})
File "/usr/sbin/auto-patch.py", line 31, in call
proc.check_returncode()
File "/usr/lib64/python3.8/subprocess.py", line 444, in check_returncode
raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['/usr/bin/zypper', '--quiet', '--non-interactive', 'patch-check']' returned non-zero exit status 7.

Add documentation

Documentation is virtually non existent. There should at least be a manual page for the auto-patch script.

Improve diagnostics: add logging and better error handling

Should improve diagnostics:

Add better error handling. Write a meaningful error message to stderr rather then letting Python emit the stack trace from the unhandled exception.

Add logging. Log relevant events such as zypper calls and return codes with level DEBUG. Log fatal errors (e.g. unhandled exceptions, see above) with level CRITICAL. Log to stderr with level DEBUG if it is a tty and to syslog with level WARN.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.