test macro

main
vitrinekast 8 months ago
parent 893e5ddce3
commit af0f985b59

@ -24,6 +24,7 @@ def run_command(command, based = False):
result = subprocess.run(command, capture_output=True, input=based)
result.check_returncode()
stripped = result.stdout.decode('UTF-8').strip()
if "No entries" in stripped:
return ""
else:
@ -32,6 +33,7 @@ def run_command(command, based = False):
# Run all the commands for getting the logs, and assign to variables
print("start running the log commands");
last_user_added = subprocess.run(["sudo", "journalctl","_COMM=useradd","-r","-n", "1" , "--output-fields=MESSAGE"], capture_output=True)
last_user_added_name = run_command(['grep', '-Po', "(?<=name)\W*\K[^ ]*"], based=last_user_added.stdout)
users_created_today = run_command(["sudo", "journalctl", "-S","today","_COMM=useradd","-r","--output-fields=MESSAGE"]).splitlines()
@ -98,8 +100,7 @@ print("Output the files");
# Export the html as book.html, which is used as an input for pandoc
with open("/home/xpub/www/html/tl-dr/book.html", "w") as f:
print(output, file=f)
print("execute the bash script now to create the books");
subprocess.run(['sh', 'create_book.sh', book_name])
subprocess.run(['sh', '/home/xpub/www/html/tl-dr/create_book.sh', book_name])
print("Finished");
# At the moment, we are not storing logs in the log folder anymore

@ -24,6 +24,16 @@
<body>
{% macro log_output(logs) -%}
{% if logs|length > 0 %}
<ul>
{% for item in logs %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endif %}
{%- endmacro %}
<article>
<h1>Debug fiesta!</h1>
<pre>
@ -107,26 +117,23 @@ user_deleted : {{ user_deleted }}
%}
</mark>
{% endif %}
<p><em>tldr@chopchop:~ $</em>sudo journalctl -S today _COMM=useradd -r</p>
<mark>
Users are assigned to groups, which allow them rights to read or edit files, run commands or apply infrastructural
changes. For chopchop, we all have 'sudo rights': the ability to perform any command, including the more sensitive
ones. Sudo is a command that's short for 'superuser do', with it, a user has more privileges, like installing or
updating a package or performing a restart.
</mark>
{% if users_created_today is defined %}
<mark>
<p><em>tldr@chopchop:~ $</em>sudo journalctl -S today _COMM=useradd -r</p>
<mark>
Users are assigned to groups, which allow them rights to read or edit files, run commands or apply infrastructural
changes. For chopchop, we all have 'sudo rights': the ability to perform any command, including the more sensitive
ones. Sudo is a command that's short for 'superuser do', with it, a user has more privileges, like installing or
updating a package or performing a restart.
</mark>
{{ log_output(users_created_today) }}
{% if users_created_today|length > 0 %}
{{last_user_name}} user was added, and the network of trust grew ever so slightly. Users will be trusted with not
just the keys and passwords to the "house" which is the server, but with a portion of responsibility to keep it
afloat and contribute to what makes it a community of practices (and network of knowledge and dependence).
<mark> {{last_user_name}} user was added, and the network of trust grew ever so slightly. Users will be trusted with not just the keys and passwords to the "house" which is the server, but with a portion of responsibility to keep it afloat and contribute to what makes it a community of practices (and network of knowledge and dependence).</mark>
{% else %}
No new users were created today. The trust network remains the same size.
<mark>No new users were created today. The trust network remains the same size.</mark>
{% endif %}
</mark>
{% endif %}
{% if list_package_installs|length > 0 %}
@ -135,11 +142,8 @@ user_deleted : {{ user_deleted }}
<mark>
Today the following packages were installed:
</mark>
<ul>
{% for item in list_package_installs %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{{ log_output(list_package_installs) }}
<mark>
Packages are often installed to use different software or coding languages or build alternative tools. Often
users have to talk about and consider which packages they need and why, as well as how much storage they take up

Loading…
Cancel
Save