From 0f34604aa6a98c4bf0f56a21396b7a6b935e27d6 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 1 May 2024 20:10:09 -0400 Subject: [PATCH] systemd services --- create_systemd_service.py | 26 ++++++++++++++++++++++++-- create_webasm_page.py | 1 + examples/emscripten.html | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/create_systemd_service.py b/create_systemd_service.py index 3cebc2b..157cf7a 100644 --- a/create_systemd_service.py +++ b/create_systemd_service.py @@ -8,6 +8,11 @@ import sys parser = argparse.ArgumentParser(prog='SystemD Service Generator', description='SystemD Service Unit File Generator', epilog='Meow') parser.add_argument("-i", "--install", nargs='?', const="/etc/systemd/system/", default=None) +parser.add_argument("-r", "--restart", default="on-failure") +parser.add_argument("-w", "--wanted", default="multi-user.target") +parser.add_argument("-d", "--working_dir", default=None) +parser.add_argument("-u", "--user", default=None) +parser.add_argument('-g', "--group", default=None) parser.add_argument("service_name", required=("--install" in sys.argv or "-i" in sys.argv), default=None) args = parser.parse_args() @@ -27,6 +32,23 @@ def bprint(*args, **kwargs): print(*args, file=f, **kwargs) if __name__ == "__main__": + description = color_io.input_print("Please enter description") + exec_string = color_io.input_print("Please enter execution string") bprint("[Unit]") - description = color_io.input_print("Please enter description: ") - bprint("") \ No newline at end of file + bprint("Description=" + description) + bprint() + bprint("[Service]") + bprint("Type=exec") + if args.working_dir is not None: + bprint("WorkingDirectory=" + args.working_dir) + if args.user is not None: + bprint("User=" + args.user) + if args.group is not None: + bprint("Group=" + args.group) + bprint("ExecStart=" + exec_string) + bprint("RestartSec=1s") + bprint("Restart=" + args.restart) + bprint("OOMPolicy=stop") + bprint() + bprint("[Install]") + bprint("WantedBy=" + args.wanted) \ No newline at end of file diff --git a/create_webasm_page.py b/create_webasm_page.py index 28e329b..e09a8c1 100755 --- a/create_webasm_page.py +++ b/create_webasm_page.py @@ -16,6 +16,7 @@ args = parser.parse_args() f = sys.stdout html_base = """ + diff --git a/examples/emscripten.html b/examples/emscripten.html index 1535753..6717c52 100644 --- a/examples/emscripten.html +++ b/examples/emscripten.html @@ -1,3 +1,4 @@ +