From b823b7bbc8c3f3f85128622cd81bf87f58a6df3f Mon Sep 17 00:00:00 2001 From: vitrinekast Date: Wed, 27 Mar 2024 00:02:28 +0100 Subject: [PATCH] some fallbacks --- script.py | 7 ++----- templates/book.jinja | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/script.py b/script.py index d8ece0c..f64c3d9 100644 --- a/script.py +++ b/script.py @@ -112,12 +112,9 @@ output = template.render( kitchen_services = kitchen_services, ip_address = ip_address, logins_today = run_command(['grep', '-v', "Boot"], based=logins_today_log.stdout).splitlines(), - list_groups = run_command(["getent","group"]).splitlines(), list_active_services = run_command(["sudo", "service", "--status-all"]).splitlines(), - debian_version = run_command(["cat", "/etc/debian_version"]), - kernel_version = run_command(["uname","-a"]), - hostname = run_command(["hostname","-i"]), - + debian_version = run_command(["cat", "/etc/debian_version"]) if time_ago_arg else False, + hostname = run_command(["hostname","-i"]) if time_ago_arg else False, groups_created = run_command(['grep', '-v', "Boot"], based=groupadd_today_log.stdout).splitlines(), groups_removed = run_command(['grep', '-v', "Boot"], based=groupremove_today_log.stdout).splitlines(), user_modified = run_command(['grep', '-v', "Boot"], based=usermod_today_log.stdout).splitlines(), diff --git a/templates/book.jinja b/templates/book.jinja index b48b840..8f8f726 100644 --- a/templates/book.jinja +++ b/templates/book.jinja @@ -64,22 +64,22 @@

The state of chopchop on {{now}}


tldr@chopchop:~ $whoami

-

{{ device_info }}

-

{{ hostname }}

-

{{ ip_address }}

+

{{ device_info if device_info else '' }}

+

{{ hostname if hostname else '' }}

+

{{ ip_address if ip_address else '' }}

XPUB 1 users use chopchop as a shared community server. chopchop is usually located in the Piet Zwart Wijnhaven building, although for this occassion it is resting on the shelf bellow this e-reader. + {% if since_last_boot is defined %}

tldr@chopchop:~ $uptime -s

Uptime is the amount of time a server has been up, available, running, working, executing. This is time that is not spent idle, but time spent busy serving.

{{ since_last_boot }}

- {% if since_last_boot is defined %} {% if days_since_last_boot|int > 14 %}This is unusual, we are used to our server crashing quite often, especially when we are all sharing the space and editing at the same time. Our server, chopchop, chops up time into small