diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install | 27 | ||||
-rwxr-xr-x | scripts/uninstall | 19 |
2 files changed, 46 insertions, 0 deletions
diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..bbba17c --- /dev/null +++ b/scripts/install @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +# vim: shiftwidth=4 tabstop=4 expandtab + + +import configparser +import jinja2 +import subprocess + + +# read config +config = configparser.ConfigParser() +config.read("./src/config.ini") +cfg = {} +for option in config.options("web-template"): + cfg[option] = config.get("web-template", option) + +# generate systemd unit file +with open("./systemd/web_template.service.jinja2", "r") as f: + template = jinja2.Template(f.read()) +unit_file = template.render(cfg) + +# install the project +subprocess.run("mkdir -p /opt/{}".format(cfg["project_name"]), shell=True) +subprocess.run("rsync --delete -vrL ./src/ /opt/{}/".format(cfg["project_name"]), shell=True) +with open("/etc/systemd/system/{}.service".format(cfg["project_name"]), "w") as f: + f.write(unit_file) + diff --git a/scripts/uninstall b/scripts/uninstall new file mode 100755 index 0000000..9b1b8e7 --- /dev/null +++ b/scripts/uninstall @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +# vim: shiftwidth=4 tabstop=4 expandtab + + +import configparser +import subprocess + + +# read config +config = configparser.ConfigParser() +config.read("./src/config.ini") +cfg = {} +for option in config.options("web-template"): + cfg[option] = config.get("web-template", option) + +# uninstall the project +subprocess.run("rm -rf /opt/{}/".format(cfg["project_name"]), shell=True) +subprocess.run("rm /etc/systemd/system/{}.service".format(cfg["project_name"]), shell=True) + |