feat(node): ship managed environment startup and USB recovery

This commit is contained in:
DCCONSTRUCTIONS
2026-09-25 16:37:56 +03:00
parent 45fb14b206
commit 53818230f9
25 changed files with 900 additions and 21 deletions
+43
View File
@@ -13,10 +13,22 @@ if [ -d /run/systemd/system ]; then
exit 1
fi
fi
mc_node_usb_job=$(systemctl show --property=ActiveState --value mission-core-node-usb-startup.service 2>/dev/null || true)
case "$mc_node_usb_job" in
activating|deactivating) echo "Mission Core Node: дождитесь завершения обнаружения USB при загрузке." >&2; exit 1 ;;
esac
if [ -f /run/mission-core-usb-startup/pending.json ]; then
echo "Mission Core Node: восстановление USB ещё не завершило включение порта; пакет сохранён." >&2
exit 1
fi
mc_node_x4_job=$(systemctl show --property=ActiveState --value mission-core-node-insta360-x4-profile.service 2>/dev/null || true)
case "$mc_node_x4_job" in
active|activating) echo "Mission Core Node: дождитесь завершения подготовки X4." >&2; exit 1 ;;
esac
mc_node_vesc_job=$(systemctl show --property=ActiveState --value mission-core-node-vesc-prepare.service 2>/dev/null || true)
case "$mc_node_vesc_job" in
active|activating) echo "Mission Core Node: дождитесь завершения подготовки VESC." >&2; exit 1 ;;
esac
mc_node_device_job=$(systemctl show --property=ActiveState --value mission-core-node-realsense-prepare.service 2>/dev/null || true)
case "$mc_node_device_job" in
active|activating) echo "Mission Core Node: дождитесь завершения подготовки устройства." >&2; exit 1 ;;
@@ -30,8 +42,39 @@ if [ -d /run/systemd/system ]; then
;;
esac
fi
retire_startup_settings() {
for mc_node_owned in /etc/xdg/autostart/org.nodedc.MissionCoreNode.desktop /etc/mission-core-node/usb-startup.json; do
case "$mc_node_owned" in
*.desktop) mc_node_template=/usr/share/mission-core-node/mission-core-node-autostart.desktop ;;
*.json) mc_node_template=/usr/share/mission-core-node/usb-startup.json ;;
esac
if [ ! -L "$mc_node_owned" ] && cmp -s "$mc_node_template" "$mc_node_owned"; then
rm "$mc_node_owned"
fi
done
if [ -d /run/systemd/system ]; then
systemctl disable --now mission-core-node-usb-startup.service
fi
}
# A downgrade removes helpers introduced in 0.8.37. Retire their owned
# configuration first; do not leave an enabled unit or XDG entry dangling.
if [ "$1" = upgrade ] && [ -n "${2:-}" ] && dpkg --compare-versions "$2" lt 0.8.37-1; then
retire_startup_settings
fi
case "$1" in
upgrade|remove|deconfigure)
if [ -d /run/systemd/system ] && [ -f /usr/lib/systemd/system/mission-core-vesc.service ]; then
systemctl disable --now mission-core-vesc.service
fi
;;
esac
case "$1" in
remove|deconfigure)
if cmp -s /usr/share/mission-core-node/profiles/vesc/70-mission-core-vesc.rules /etc/udev/rules.d/70-mission-core-vesc.rules; then
rm /etc/udev/rules.d/70-mission-core-vesc.rules
if [ -d /run/systemd/system ]; then udevadm control --reload-rules; fi
fi
retire_startup_settings
mc_node_ssh_snippet=/etc/ssh/sshd_config.d/60-mission-core-node.conf
if [ -e "$mc_node_ssh_snippet" ]; then
if cmp -s /usr/share/mission-core-node/60-mission-core-node.conf "$mc_node_ssh_snippet"; then