From 69c6de9f9c7a5f6107a70f83004d17cb7771ca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Gr=C3=A9goire?= Date: Sat, 19 Aug 2017 16:41:50 -0400 Subject: [PATCH] explorer/os: get ID from /etc/os-release /etc/os-release was introduced by systemd[1] and is now more and more common; even on systems without systemd (e.g. lede). In addition to detecting the OS based on specific attributes, this file provides the ID marker to describe the OS. This commit adds support for OS detection via /etc/os-release. According to [2], it is already lowercase. [1] http://0pointer.de/blog/projects/os-release [2] https://www.freedesktop.org/software/systemd/man/os-release.html --- cdist/conf/explorer/os | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cdist/conf/explorer/os b/cdist/conf/explorer/os index 094685ea..e0125c1b 100755 --- a/cdist/conf/explorer/os +++ b/cdist/conf/explorer/os @@ -1,6 +1,7 @@ #!/bin/sh # # 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) +# Copyright 2017, Philippe Gregoire # # This file is part of cdist. # @@ -139,5 +140,12 @@ case "$uname_s" in ;; esac +if [ -f /etc/os-release ]; then + # already lowercase, according to: + # https://www.freedesktop.org/software/systemd/man/os-release.html + grep '^ID=' /etc/os-release | sed -e 's|^ID=||' + exit 0 +fi + echo "Unknown OS" >&2 exit 1