From 04c632953d4723770988b1f3a4b9b885e12675d2 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 20 Sep 2020 15:05:17 +0200 Subject: [PATCH] bundles/octoprint: introduce --- bundles/octoprint/files/octoprint.service | 15 ++++++++++ bundles/octoprint/items.py | 34 +++++++++++++++++++++++ bundles/octoprint/metadata.py | 7 +++++ 3 files changed, 56 insertions(+) create mode 100644 bundles/octoprint/files/octoprint.service create mode 100644 bundles/octoprint/items.py create mode 100644 bundles/octoprint/metadata.py diff --git a/bundles/octoprint/files/octoprint.service b/bundles/octoprint/files/octoprint.service new file mode 100644 index 0000000..d3681c2 --- /dev/null +++ b/bundles/octoprint/files/octoprint.service @@ -0,0 +1,15 @@ +[Unit] +Description=OctoPrint +After=network.target + +[Service] +User=octoprint +Group=octoprint +Environment="VIRTUAL_ENV=/opt/octoprint/venv" +Environment="PATH=/opt/octoprint/venv/bin:/usr/local/bin:/usr/bin:/bin" +ExecStart=/opt/octoprint/venv/bin/octoprint serve --ipv6 --host ::1 --port 22030 +WorkingDirectory=/opt/octoprint +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/bundles/octoprint/items.py b/bundles/octoprint/items.py new file mode 100644 index 0000000..13e1bec --- /dev/null +++ b/bundles/octoprint/items.py @@ -0,0 +1,34 @@ +actions = { + 'octoprint_create_virtualenv': { + 'command': 'sudo -u octoprint /usr/bin/python3 -m virtualenv -p python3 /opt/octoprint/venv/', + 'unless': 'test -d /opt/octoprint/venv/', + 'needs': { + 'directory:/opt/octoprint', # provided by bundle:users + 'user:octoprint', + }, + }, + 'octoprint_install_octoprint': { + 'command': 'sudo -u octoprint /opt/octoprint/venv/bin/pip install OctoPrint', + 'unless': 'test -f /opt/octoprint/venv/bin/octoprint', + 'needs': { + 'action:octoprint_create_virtualenv', + }, + }, +} + +svc_systemd = { + 'octoprint': { + 'needs': { + 'file:/etc/systemd/system/octoprint.service', + 'action:octoprint_install_octoprint', + }, + }, +} + +files = { + '/etc/systemd/system/octoprint.service': { + 'triggers': { + 'action:systemd-reload', + }, + }, +} diff --git a/bundles/octoprint/metadata.py b/bundles/octoprint/metadata.py new file mode 100644 index 0000000..f1f419a --- /dev/null +++ b/bundles/octoprint/metadata.py @@ -0,0 +1,7 @@ +defaults = { + 'users': { + 'octoprint': { + 'home': '/opt/octoprint', + }, + }, +}