summaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-03-07 11:10:38 +0100
committerxengineering <mail2xengineering@protonmail.com>2021-03-07 11:10:38 +0100
commit249d11ccee0bccbd4785794913c44c2eafc2c460 (patch)
tree40c81495e3773452732abece93db8979c3cd2a90 /scripts/install
parent47b30cea327420ed6f17ccc6fd521ad89f4b4e4f (diff)
downloadweb-template-249d11ccee0bccbd4785794913c44c2eafc2c460.tar
web-template-249d11ccee0bccbd4785794913c44c2eafc2c460.tar.zst
web-template-249d11ccee0bccbd4785794913c44c2eafc2c460.zip
Implement Deployment
Diffstat (limited to 'scripts/install')
-rwxr-xr-xscripts/install27
1 files changed, 27 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)
+