From d02538368a204342a3d6b77e0df1954b23140151 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Tue, 22 Sep 2020 18:52:11 +0200 Subject: [PATCH] bundles/octoprint: add systemd-wrapper script --- bundles/octoprint/files/systemd-wrapper | 22 ++++++++++++++++++++++ bundles/octoprint/items.py | 3 +++ bundles/octoprint/metadata.py | 1 + 3 files changed, 26 insertions(+) create mode 100644 bundles/octoprint/files/systemd-wrapper diff --git a/bundles/octoprint/files/systemd-wrapper b/bundles/octoprint/files/systemd-wrapper new file mode 100644 index 0000000..be4414e --- /dev/null +++ b/bundles/octoprint/files/systemd-wrapper @@ -0,0 +1,22 @@ +#!/bin/bash + +systemctl=$(command -v systemctl) + +if [[ -z "$systemctl" ]]; then + echo "systemctl not found" + exit 1 +fi + +if [[ "$1" == "restart-octoprint" ]]; then + $systemctl restart octoprint + +elif [[ "$1" == "restart-system" ]]; then + $systemctl reboot + +elif [[ "$1" == "shutdown-system" ]]; then + $systemctl poweroff + +else + echo "unknown command" + exit 1 +fi diff --git a/bundles/octoprint/items.py b/bundles/octoprint/items.py index 8d6831c..86674ef 100644 --- a/bundles/octoprint/items.py +++ b/bundles/octoprint/items.py @@ -32,4 +32,7 @@ files = { 'svc_systemd:octoprint:restart', }, }, + '/opt/octoprint/systemd-wrapper': { + 'mode': '0755', + }, } diff --git a/bundles/octoprint/metadata.py b/bundles/octoprint/metadata.py index dc5a5c6..812b840 100644 --- a/bundles/octoprint/metadata.py +++ b/bundles/octoprint/metadata.py @@ -4,6 +4,7 @@ defaults = { 'home': '/opt/octoprint', 'sudo_commands': { '/usr/bin/vcgencmd', + '/opt/octoprint/systemd-wrapper', }, }, },