diff mbox

[ovs-dev] ovs-ctl: support populating system info from /etc/os-release

Message ID 0fc98c872a32fd2e45522fb49e68e0adfd34fa24.1470827774.git.pmatilai@redhat.com
State Accepted
Headers show

Commit Message

Panu Matilainen Aug. 10, 2016, 11:16 a.m. UTC
On systemd-era hosts, OS name and version are available in sanitized
format from /etc/os-release(5) without resorting to calling (and thus
requiring) lsb_release. Support populating system-type and system-version
from /etc/os-release, prefer it over lsb_release, but permit overriding
via the OVS-specific system-type.conf and system-version.conf.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1350550
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
---
 utilities/ovs-ctl.in | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ben Pfaff Aug. 10, 2016, 4:46 p.m. UTC | #1
On Wed, Aug 10, 2016 at 02:16:14PM +0300, Panu Matilainen wrote:
> On systemd-era hosts, OS name and version are available in sanitized
> format from /etc/os-release(5) without resorting to calling (and thus
> requiring) lsb_release. Support populating system-type and system-version
> from /etc/os-release, prefer it over lsb_release, but permit overriding
> via the OVS-specific system-type.conf and system-version.conf.
> 
> Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1350550
> Signed-off-by: Panu Matilainen <pmatilai@redhat.com>

Applied, thanks!
diff mbox

Patch

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index d92cf3c..ff3eaf2 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -522,6 +522,9 @@  set_defaults () {
     if test -e "$type_file" ; then
         SYSTEM_TYPE=`cat $type_file`
         SYSTEM_VERSION=`cat $version_file`
+    elif test -e "@sysconfdir@/os-release"; then
+        SYSTEM_TYPE=`awk -F= '/^ID=/{print $2}' @sysconfdir@/os-release`
+        SYSTEM_VERSION=`awk -F= '/^VERSION_ID=/{print $2}' @sysconfdir@/os-release`
     elif (lsb_release --id) >/dev/null 2>&1; then
         SYSTEM_TYPE=`lsb_release --id -s`
         system_release=`lsb_release --release -s`