#!/usr/bin/env bash
set -e

# Stop voxl-px4 service if running
if command -v systemctl > /dev/null 2>&1; then
    systemctl stop voxl-px4 2>/dev/null || true
fi

# Remove px4-* symlinks
for f in /usr/bin/px4-*; do
    if [ -L "$f" ] && [ "$(readlink "$f")" = "px4" ]; then
        rm -f "$f"
    fi
done
