From f406eb28276fa87a3576122491be4e1921ab9a13 Mon Sep 17 00:00:00 2001
From: j1nx
Date: Sat, 8 Oct 2022 17:52:34 +0200
Subject: [PATCH] Switch over to user systemd services
---
.../configs/rpi4_64-gui_defconfig | 1 -
.../default.target.wants/kdeconnectd.service | 1 +
.../user/default.target.wants/mycroft.service | 1 +
.../mycroft-audio.service | 1 +
.../mycroft-enclosure-gui.service | 1 +
.../mycroft.service.wants/mycroft-gui.service | 1 +
.../mycroft-messagebus.service | 1 +
.../mycroft-phal.service | 1 +
.../mycroft-skills.service | 1 +
.../mycroft-voice.service | 1 +
.../home/mycroft/.local/state/mycroft/.empty | 0
.../rootfs-overlay/usr/bin/bus-monitor | 0
.../rootfs-overlay/usr/bin/node-red-log | 13 ----
.../rootfs-overlay/usr/bin/node-red-reload | 2 -
.../rootfs-overlay/usr/bin/node-red-restart | 3 -
.../rootfs-overlay/usr/bin/node-red-start | 75 -------------------
.../rootfs-overlay/usr/bin/node-red-stop | 8 --
.../lib/systemd/system-preset/10-ovos.preset | 8 --
.../lib/systemd/user-preset/10-ovos.preset | 15 ++++
.../usr/lib/systemd/user/kdeconnectd.service | 3 +
.../lib/systemd/user/mycroft-audio.service | 22 ++++++
.../user/mycroft-enclosure-gui.service | 21 ++++++
.../usr/lib/systemd/user/mycroft-gui.service | 11 +++
.../systemd/user/mycroft-messagebus.service | 20 +++++
.../usr/lib/systemd/user/mycroft-phal.service | 21 ++++++
.../lib/systemd/user/mycroft-skills.service | 21 ++++++
.../lib/systemd/user/mycroft-voice.service | 23 ++++++
.../usr/lib/systemd/user/mycroft.service | 10 +++
.../usr/libexec/mycroft-systemd-audio | 30 ++++++++
.../usr/libexec/mycroft-systemd-gui | 30 ++++++++
.../usr/libexec/mycroft-systemd-messagebus | 30 ++++++++
.../usr/libexec/mycroft-systemd-phal | 30 ++++++++
.../usr/libexec/mycroft-systemd-skills | 30 ++++++++
.../usr/libexec/mycroft-systemd-voice | 30 ++++++++
34 files changed, 356 insertions(+), 110 deletions(-)
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/kdeconnectd.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/mycroft.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-audio.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-enclosure-gui.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-gui.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-messagebus.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-phal.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-skills.service
create mode 120000 buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-voice.service
create mode 100644 buildroot-external/rootfs-overlay/home/mycroft/.local/state/mycroft/.empty
mode change 100644 => 100755 buildroot-external/rootfs-overlay/usr/bin/bus-monitor
delete mode 100755 buildroot-external/rootfs-overlay/usr/bin/node-red-log
delete mode 100755 buildroot-external/rootfs-overlay/usr/bin/node-red-reload
delete mode 100755 buildroot-external/rootfs-overlay/usr/bin/node-red-restart
delete mode 100755 buildroot-external/rootfs-overlay/usr/bin/node-red-start
delete mode 100755 buildroot-external/rootfs-overlay/usr/bin/node-red-stop
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user-preset/10-ovos.preset
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-audio.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-enclosure-gui.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-gui.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-messagebus.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-phal.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-skills.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-voice.service
create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft.service
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-audio
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-gui
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-messagebus
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-phal
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-skills
create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-voice
diff --git a/buildroot-external/configs/rpi4_64-gui_defconfig b/buildroot-external/configs/rpi4_64-gui_defconfig
index 47190b25..5c607d3b 100644
--- a/buildroot-external/configs/rpi4_64-gui_defconfig
+++ b/buildroot-external/configs/rpi4_64-gui_defconfig
@@ -688,7 +688,6 @@ BR2_PACKAGE_MYCROFT_GUI=y
BR2_PACKAGE_PYTHON_OVOS_CLI_CLIENT=y
BR2_PACKAGE_PYTHON_OVOS_CONFIG=y
BR2_PACKAGE_PYTHON_OVOS_CORE=y
-BR2_PACKAGE_MYCROFT_SERVICE=y
BR2_PACKAGE_PYTHON_OVOS_AUDIO_PLUGIN_SIMPLE=y
BR2_PACKAGE_PYTHON_OVOS_BACKEND_CLIENT=y
BR2_PACKAGE_PYTHON_OVOS_BACKEND_MANAGER=y
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/kdeconnectd.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/kdeconnectd.service
new file mode 120000
index 00000000..42c11023
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/kdeconnectd.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/kdeconnectd.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/mycroft.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/mycroft.service
new file mode 120000
index 00000000..6f7df584
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/default.target.wants/mycroft.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-audio.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-audio.service
new file mode 120000
index 00000000..a23e08bb
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-audio.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-audio.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-enclosure-gui.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-enclosure-gui.service
new file mode 120000
index 00000000..82f52b11
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-enclosure-gui.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-enclosure-gui.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-gui.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-gui.service
new file mode 120000
index 00000000..3e375eda
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-gui.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-gui.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-messagebus.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-messagebus.service
new file mode 120000
index 00000000..a7b459ce
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-messagebus.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-messagebus.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-phal.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-phal.service
new file mode 120000
index 00000000..fc7fdc5a
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-phal.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-phal.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-skills.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-skills.service
new file mode 120000
index 00000000..1027d626
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-skills.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-skills.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-voice.service b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-voice.service
new file mode 120000
index 00000000..7a66555f
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/home/mycroft/.config/systemd/user/mycroft.service.wants/mycroft-voice.service
@@ -0,0 +1 @@
+../../../../../../usr/lib/systemd/user/mycroft-voice.service
\ No newline at end of file
diff --git a/buildroot-external/rootfs-overlay/home/mycroft/.local/state/mycroft/.empty b/buildroot-external/rootfs-overlay/home/mycroft/.local/state/mycroft/.empty
new file mode 100644
index 00000000..e69de29b
diff --git a/buildroot-external/rootfs-overlay/usr/bin/bus-monitor b/buildroot-external/rootfs-overlay/usr/bin/bus-monitor
old mode 100644
new mode 100755
diff --git a/buildroot-external/rootfs-overlay/usr/bin/node-red-log b/buildroot-external/rootfs-overlay/usr/bin/node-red-log
deleted file mode 100755
index b200450e..00000000
--- a/buildroot-external/rootfs-overlay/usr/bin/node-red-log
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-LINES=25
-while getopts ":n:" opt; do
- case $opt in
- n) LINES="$OPTARG"
- ;;
- \?) echo "Unrecognized option -$OPTARG. Usage: node-red-log [-n lines]. For example: node-red-log -n 50" >&2 && exit 1
- ;;
- esac
-done
-echo -e '\033]2;'Node-RED log'\007'
-echo " "
-sudo journalctl -f -n $LINES -u nodered -o cat
diff --git a/buildroot-external/rootfs-overlay/usr/bin/node-red-reload b/buildroot-external/rootfs-overlay/usr/bin/node-red-reload
deleted file mode 100755
index 33118009..00000000
--- a/buildroot-external/rootfs-overlay/usr/bin/node-red-reload
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-sudo node-red-stop && sudo node-red-start
diff --git a/buildroot-external/rootfs-overlay/usr/bin/node-red-restart b/buildroot-external/rootfs-overlay/usr/bin/node-red-restart
deleted file mode 100755
index bffee103..00000000
--- a/buildroot-external/rootfs-overlay/usr/bin/node-red-restart
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-sudo systemctl restart nodered
-echo -e "\033[1mRestarted \033[38;5;88mNode-RED\033[0m"
diff --git a/buildroot-external/rootfs-overlay/usr/bin/node-red-start b/buildroot-external/rootfs-overlay/usr/bin/node-red-start
deleted file mode 100755
index 7892c168..00000000
--- a/buildroot-external/rootfs-overlay/usr/bin/node-red-start
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2016,2020 JS Foundation and other contributors, https://js.foundation/
-# Copyright 2015,2016 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-echo -e '\033]2;'Node-RED console'\007'
-if [[ $(which node-red-pi) ]]; then
- if [[ ! $(which npm) ]]; then
- echo -e "\033[0m \033[0m"
- echo -e "\033[0m npm is not installed, it is recommended \033[0m"
- echo -e "\033[0m to install the latest by running: \033[0m"
- echo -e "\033[0m update-nodejs-and-nodered \033[0m"
- echo -e "\033[0m \033[0m"
- echo -e " "
- fi
- HOSTIP=`hostname -I | cut -d ' ' -f 1`
- if [ "$HOSTIP" = "" ]; then
- HOSTIP="127.0.0.1"
- fi
- echo -e "\033[1mStart \033[38;5;88mNode-RED\033[0m"
- echo " "
- echo "Once Node-RED has started, point a browser at http://$HOSTIP:1880"
- echo "On Pi Node-RED works better with the Firefox or Chrome browser"
- echo " "
- if groups | grep -q -w sudo; then
- echo -e "Use \033[0;36mnode-red-stop\033[0m to stop Node-RED"
- echo -e "Use \033[0;36mnode-red-start\033[0m to start Node-RED again"
- echo -e "Use \033[0;36mnode-red-log\033[0m to view the recent log output"
- fi
- echo -e "Use \033[0;36msudo systemctl enable nodered.service\033[0m to autostart Node-RED at every boot"
- echo -e "Use \033[0;36msudo systemctl disable nodered.service\033[0m to disable autostart on boot"
- echo " "
- echo "To find more nodes and example flows - go to http://flows.nodered.org"
- if [ "$nv" = "v0" ]; then
- echo "You may also need to install and upgrade npm"
- echo -e " \033[0;36msudo apt-get install npm\033[0m"
- echo -e " \033[0;36msudo npm i -g npm@2.x\033[0m"
- fi
- if groups $USER | grep -q -w sudo; then
- # Current user is member of sudo group, start node-red through systemd
- sudo systemctl start nodered
- echo " "
- echo "Starting as a systemd service."
- sudo journalctl -f -n 0 -u nodered -o cat
- elif [ $EUID -eq 0 ]; then
- # Current user is root, start node-red through systemd
- systemctl start nodered
- echo " "
- echo "Starting as root systemd service."
- journalctl -f -n 0 -u nodered -o cat
- else
- # Start node-red as unprivileged user
- echo " "
- echo "Starting as a normal user."
- node-red-pi
- fi
-else
- echo "Node-RED is not yet fully installed. Please re-run the install script again manually."
- echo " "
- echo " bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)"
- echo " "
- echo "then retry node-red-start"
- echo " "
-fi
diff --git a/buildroot-external/rootfs-overlay/usr/bin/node-red-stop b/buildroot-external/rootfs-overlay/usr/bin/node-red-stop
deleted file mode 100755
index 50de1854..00000000
--- a/buildroot-external/rootfs-overlay/usr/bin/node-red-stop
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-echo -e '\033]2;'Node-RED console'\007'
-echo -e "\033[1mStop \033[38;5;88mNode-RED\033[0m"
-echo " "
-echo -e "Use \033[0;36mnode-red-start\033[0m to start Node-RED again"
-sudo systemctl stop nodered
-echo " "
-exit
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-ovos.preset b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-ovos.preset
index 0b6032ec..8b1fe952 100644
--- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-ovos.preset
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-ovos.preset
@@ -9,14 +9,6 @@ enable NetworkManager.service
enable getty@tty1.service
enable ovos-splash-start.service
enable ovos-splash-systemd.service
-enable mycroft.service
-enable mycroft-messagebus.service
-enable mycroft-voice.service
-enable mycroft-audio.service
-enable mycroft-skills.service
-enable mycroft-gui.service
-enable mycroft-enclosure-gui.service
-enable mycroft-phal.service
enable ovos-splash-quit.service
enable local-backend.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user-preset/10-ovos.preset b/buildroot-external/rootfs-overlay/usr/lib/systemd/user-preset/10-ovos.preset
new file mode 100644
index 00000000..b6884fb5
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user-preset/10-ovos.preset
@@ -0,0 +1,15 @@
+disable pulseaudio.service
+disable pulseaudio.socket
+
+enable mycroft.service
+enable mycroft-messagebus.service
+enable mycroft-voice.service
+enable mycroft-audio.service
+enable mycroft-skills.service
+enable mycroft-gui.service
+enable mycroft-enclosure-gui.service
+enable mycroft-phal.service
+
+enable local-backend.service
+
+enable kdeconnectd.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/kdeconnectd.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/kdeconnectd.service
index 1f9a15ea..6347587d 100644
--- a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/kdeconnectd.service
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/kdeconnectd.service
@@ -4,3 +4,6 @@ Description=Connect your OVOS-Device to your smartphone or tablet
[Service]
ExecStart=/usr/lib/libexec/kdeconnectd -platform offscreen
BusName=org.kde.kdeconnect
+
+[Install]
+WantedBy=default.target
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-audio.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-audio.service
new file mode 100644
index 00000000..e7dd1a53
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-audio.service
@@ -0,0 +1,22 @@
+[Unit]
+Description=Mycroft Audio
+PartOf=mycroft.service
+After=mycroft.service
+After=mycroft-messagebus.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-audio
+StandardOutput=append:/home/mycroft/.local/state/mycroft/audio.log
+StandardError=file:/home/mycroft/.local/state/mycroft/audio.error.log
+TimeoutStartSec=1m
+TimeoutStopSec=1m
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
+
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-enclosure-gui.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-enclosure-gui.service
new file mode 100644
index 00000000..58cff1e0
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-enclosure-gui.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Mycroft Enclosure
+PartOf=mycroft.service
+After=mycroft.service
+After=mycroft-messagebus.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-gui
+StandardOutput=append:/home/mycroft/.local/state/mycroft/enclosure_gui.log
+StandardError=file:/home/mycroft/.local/state/mycroft/enclosure_gui.error.log
+TimeoutStartSec=1m
+TimeoutStopSec=1m
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-gui.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-gui.service
new file mode 100644
index 00000000..1c923afc
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-gui.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Mycroft GUI
+
+[Service]
+ExecStartPre=-/usr/bin/kbuildsycoca5
+ExecStart=ovos-shell --maximize
+StandardOutput=null
+Restart=on-failure
+
+[Install]
+WantedBy=mycroft.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-messagebus.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-messagebus.service
new file mode 100644
index 00000000..387c4d7b
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-messagebus.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Mycroft Messagebus
+PartOf=mycroft.service
+After=mycroft.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-messagebus
+StandardOutput=append:/home/mycroft/.local/state/mycroft/bus.log
+StandardError=file:/home/mycroft/.local/state/mycroft/bus.error.log
+TimeoutStartSec=1m
+TimeoutStopSec=1m
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-phal.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-phal.service
new file mode 100644
index 00000000..c5163f5c
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-phal.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Mycroft PHAL
+PartOf=mycroft.service
+After=mycroft.service
+After=mycroft-messagebus.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-phal
+StandardOutput=append:/home/mycroft/.local/state/mycroft/phal.log
+StandardError=file:/home/mycroft/.local/state/mycroft/phal.error.log
+TimeoutStartSec=1m
+TimeoutStopSec=1m
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-skills.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-skills.service
new file mode 100644
index 00000000..ef4d3607
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-skills.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Mycroft Skills
+PartOf=mycroft.service
+After=mycroft.service
+After=mycroft-messagebus.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-skills
+StandardOutput=append:/home/mycroft/.local/state/mycroft/skills.log
+StandardError=file:/home/mycroft/.local/state/mycroft/skills.error.log
+TimeoutStartSec=10m
+TimeoutStopSec=1m
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-voice.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-voice.service
new file mode 100644
index 00000000..446b39c7
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft-voice.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Mycroft Voice
+PartOf=mycroft.service
+After=mycroft.service
+After=mycroft-messagebus.service
+
+[Service]
+Type=notify
+ExecStart=/usr/libexec/mycroft-systemd-voice
+StandardOutput=append:/home/mycroft/.local/state/mycroft/voice.log
+StandardError=file:/home/mycroft/.local/state/mycroft/voice.error.log
+TimeoutStartSec=1m
+TimeoutStopSec=1m
+Restart=on-failure
+Restart=on-failure
+StartLimitInterval=5min
+StartLimitBurst=4
+#StartLimitAction=reboot-force
+#WatchdogSec=30s
+
+[Install]
+WantedBy=mycroft.service
+
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft.service
new file mode 100644
index 00000000..05023c24
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/user/mycroft.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Mycroft A.I. Software stack.
+
+[Service]
+Type=oneshot
+ExecStart=/bin/true
+RemainAfterExit=yes
+
+[Install]
+WantedBy=default.target
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-audio b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-audio
new file mode 100755
index 00000000..b4d6af64
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-audio
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_audio.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from mycroft.audio.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Audio service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Audio service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-gui b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-gui
new file mode 100755
index 00000000..f2268292
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-gui
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_enclosure.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from mycroft.gui.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Enclosure GUI service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Enclosure GUI service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-messagebus b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-messagebus
new file mode 100755
index 00000000..49278b27
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-messagebus
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_messagebus.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from mycroft.messagebus.service.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Messagebus service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Messagebus service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-phal b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-phal
new file mode 100755
index 00000000..40ed4c37
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-phal
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_enclosure.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from ovos_PHAL.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Enclosure Client service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Enclosure Client service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-skills b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-skills
new file mode 100755
index 00000000..02aab4e4
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-skills
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_skills.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from mycroft.skills.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Skills service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Skills service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)
diff --git a/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-voice b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-voice
new file mode 100755
index 00000000..fd0b36ee
--- /dev/null
+++ b/buildroot-external/rootfs-overlay/usr/libexec/mycroft-systemd-voice
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+##########################################################################
+# mycroft-systemd_voice.py
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+import sdnotify
+from mycroft.client.speech.__main__ import main
+
+n = sdnotify.SystemdNotifier()
+
+def notify_ready():
+ n.notify('READY=1')
+ print('Startup of Mycroft Voice service complete')
+
+def notify_stopping():
+ n.notify('STOPPING=1')
+ print('Stopping the Mycroft Voice service')
+
+main(ready_hook=notify_ready, stopping_hook=notify_stopping)