From 20c9932c6fe43d2b4b628534eb2c224e41b80d5f Mon Sep 17 00:00:00 2001 From: Thorsten Spille Date: Sun, 16 Oct 2022 15:05:20 +0200 Subject: [PATCH] Update check_release_info --- release-info/check_release_info | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/release-info/check_release_info b/release-info/check_release_info index 4ed11be..f676220 100644 --- a/release-info/check_release_info +++ b/release-info/check_release_info @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# +# Prints the debian/ubuntu release info and sets state by codename +# The package 'lsb-release' is required for this check. import subprocess @@ -6,9 +9,15 @@ ok_list = ['bullseye', 'bookworm', 'trixie', 'forky', 'jammy', 'focal'] warn_list = ['buster', 'bionic', 'xenial'] cmd = ["/usr/bin/lsb_release", "-ircs"] + stdout, stderr = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate() dist, version, codename, null = stdout.decode('utf-8').split('\n') -state: int = 0 if codename in ok_list else (1 if codename in warn_list else 2) +if codename in ok_list: + state = 0 +elif codename in warn_list: + state = 1 +else: + state = 2 -print (f'{state} "Distribution Info" - {dist} {version} {codename}') +print ('%s "Distribution Info" - %s %s %s' % (state, dist, version, codename))