Switch over to user systemd services

This commit is contained in:
j1nx 2022-10-08 17:52:34 +02:00
parent a8f16fba66
commit f406eb2827
34 changed files with 356 additions and 110 deletions

View File

@ -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

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/kdeconnectd.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-audio.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-enclosure-gui.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-gui.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-messagebus.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-phal.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-skills.service

View File

@ -0,0 +1 @@
../../../../../../usr/lib/systemd/user/mycroft-voice.service

0
buildroot-external/rootfs-overlay/usr/bin/bus-monitor Normal file → Executable file
View File

View File

@ -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

View File

@ -1,2 +0,0 @@
#!/bin/bash
sudo node-red-stop && sudo node-red-start

View File

@ -1,3 +0,0 @@
#!/bin/bash
sudo systemctl restart nodered
echo -e "\033[1mRestarted \033[38;5;88mNode-RED\033[0m"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,10 @@
[Unit]
Description=Mycroft A.I. Software stack.
[Service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=yes
[Install]
WantedBy=default.target

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)