diff --git a/script.py b/script.py index 0921780..bf6d0c1 100644 --- a/script.py +++ b/script.py @@ -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 diff --git a/templates/book.jinja b/templates/book.jinja index 334524d..9b56887 100644 --- a/templates/book.jinja +++ b/templates/book.jinja @@ -24,6 +24,16 @@ + {% macro log_output(logs) -%} + {% if logs|length > 0 %} + + {% endif %} +{%- endmacro %} +

Debug fiesta!

@@ -107,26 +117,23 @@ user_deleted : {{ user_deleted }}
       %}
     
     {% endif %}
-
-    

tldr@chopchop:~ $sudo journalctl -S today _COMM=useradd -r

- - 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. - - - + {% if users_created_today is defined %} - +

tldr@chopchop:~ $sudo journalctl -S today _COMM=useradd -r

+ + 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. + + + {{ 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). + {{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). {% else %} - No new users were created today. The trust network remains the same size. + No new users were created today. The trust network remains the same size. {% endif %} -
+ {% endif %} {% if list_package_installs|length > 0 %} @@ -135,11 +142,8 @@ user_deleted : {{ user_deleted }} Today the following packages were installed: - + + {{ log_output(list_package_installs) }} 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