uzbek-plus/b14/run/ui-stop.sh

10 lines
819 B
Bash

#!/bin/sh
# B14: stop Cage + aurora-ui (and wayvnc if it was attached); fbcon/tty1 comes back when Cage releases the VT.
uipid() { for p in /proc/[0-9]*; do [ "$(readlink $p/exe 2>/dev/null)" = /usr/local/bin/aurora-ui ] && echo ${p#/proc/}; done; } # not pidof: /etc/init.d/aurora-ui has the same comm
D=/run/aurora-ui; L=$D/ui.log; mkdir -p $D
pidof wayvnc >/dev/null && sh /usr/local/lib/b13/run/wayvnc-down.sh >/dev/null 2>&1
P=$(cat $D/cage.pid 2>/dev/null)
if [ -n "$P" ] && kill -0 $P 2>/dev/null; then kill $P; i=0; while kill -0 $P 2>/dev/null && [ $i -lt 50 ]; do sleep 0.1; i=$((i+1)); done; kill -0 $P 2>/dev/null && kill -9 $P; fi
P2=$(uipid); [ -n "$P2" ] && kill $P2
rm -f $D/cage.pid $D/wayland-display
echo "[$(cut -d' ' -f1 /proc/uptime)] UI STOPPED vt=$(cat /sys/class/tty/tty0/active)" | tee -a $L