From 88e5ec963bd60b6d5859312fc37be2f5ddae489c Mon Sep 17 00:00:00 2001 From: Arnaud Rebillout Date: Fri, 16 Jul 2021 09:22:41 +0700 Subject: [PATCH] Favor os-release over debian_version, as it gives more details on the host OS On a Debian unstable system, the file `/etc/debian_version` contains only `11.0`, so the script `build.sh` gives me this kind of log: OS: 11.0 Not super informative. However the file `/usr/lib/os-release` provides more details, and by using it we can get the following log: OS: Debian GNU/Linux 11 (bullseye) For a Kali system: OS: Kali GNU/Linux 2021.2 --- build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 2e52118..e95a81d 100755 --- a/build.sh +++ b/build.sh @@ -198,7 +198,9 @@ debug "KALI_DIST: $KALI_DIST" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" debug "PATH: $PATH" -if [ -e /etc/debian_version ]; then +if grep -q -e "^ID=debian" -e "^ID_LIKE=debian" /usr/lib/os-release; then + debug "OS: $( . /usr/lib/os-release && echo $NAME $VERSION )" +elif [ -e /etc/debian_version ]; then debug "OS: $( cat /etc/debian_version )" else echo "ERROR: Non Debian-based OS" >&2