summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamectl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-21 03:35:33 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-21 03:35:54 +0200
commitfe29f9d25bb58b9d5c5581a2991d40358d2c8b31 (patch)
treef359f2963319ef2201f95154d4e63a1d9db99fb8 /src/hostname/hostnamectl.c
parent7cd28a8a2fdf01293b0c07681a5f36f557fe51b4 (diff)
hostnamectl: add more really basic system info to the status output
Diffstat (limited to 'src/hostname/hostnamectl.c')
-rw-r--r--src/hostname/hostnamectl.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index 33245dd4f9..1d448bd944 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -25,6 +25,7 @@
#include <getopt.h>
#include <string.h>
#include <sys/timex.h>
+#include <sys/utsname.h>
#include "dbus-common.h"
#include "util.h"
@@ -66,7 +67,9 @@ typedef struct StatusInfo {
static void print_status_info(StatusInfo *i) {
sd_id128_t mid, bid;
int r;
- const char *id;
+ const char *id = NULL;
+ _cleanup_free_ char *pretty_name = NULL, *cpe_name = NULL;
+ struct utsname u;
assert(i);
@@ -90,8 +93,24 @@ static void print_status_info(StatusInfo *i) {
if (r >= 0)
printf(" Boot ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(bid));
- if (detect_virtualization(&id) >= 0)
+ if (detect_virtualization(&id) > 0)
printf(" Virtualization: %s\n", id);
+
+ r = parse_env_file("/etc/os-release", NEWLINE,
+ "PRETTY_NAME", &pretty_name,
+ "CPE_NAME", &cpe_name,
+ NULL);
+
+ if (!isempty(pretty_name))
+ printf(" Operating System: %s\n", pretty_name);
+
+ if (!isempty(cpe_name))
+ printf(" CPE OS Name: %s\n", cpe_name);
+
+ assert_se(uname(&u) >= 0);
+ printf(" Kernel: %s %s\n"
+ " Architecture: %s\n", u.sysname, u.release, u.machine);
+
}
static int status_property(const char *name, DBusMessageIter *iter, StatusInfo *i) {