#!/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
