Fix desktop and udev launch scripts

These services were not responding to a SIGTERM
We need to catch the SIGTERM from the parent script and kill the child process
This commit is contained in:
Josh.5
2022-10-02 11:37:43 +00:00
committed by Josh Sunnex
parent 7614e503a7
commit 2c0b7b5d53
4 changed files with 49 additions and 14 deletions

32
overlay/usr/bin/start-udev.sh Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
###
# File: start-xorg.sh
# File: start-udev.sh
# Project: bin
# File Created: Tuesday, 12th January 2022 8:46:47 am
# Author: Josh.5 (jsunnex@gmail.com)
@@ -9,15 +9,33 @@
# Modified By: Josh.5 (jsunnex@gmail.com)
###
# CATCH TERM SIGNAL:
_term() {
kill -TERM "$monitor_pid" 2>/dev/null
kill -TERM "$trigger_pid" 2>/dev/null
kill -TERM "$udevd_pid" 2>/dev/null
}
trap _term SIGTERM
# EXECUTE PROCESS:
# Start udev
# Source: https://github.com/balena-io-playground/balena-base-images/
if command -v udevd &> /dev/null; then
unshare --net udevd --daemon &> /dev/null
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &>/dev/null
udevd_pid=$!
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
unshare --net /lib/systemd/systemd-udevd --daemon &>/dev/null
udevd_pid=$!
fi
udevadm trigger &> /dev/null
udevadm trigger &>/dev/null
trigger_pid=$!
# Monitor kernel uevents
udevadm monitor &
monitor_pid=$!
# Monitry kernel uevents
udevadm monitor
# WAIT FOR CHILD PROCESS:
wait "$monitor_pid"
wait "$trigger_pid"
wait "$udevd_pid"