Integrate lgv_dev_tc_motor arm planning dependencies while retaining linbo_dev capabilities. Configure seven TCHL axes, preserve existing limits and igc startup defaults, and sync build script updates through 08d9a393.
71 lines
1.6 KiB
Bash
Executable File
71 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'USAGE'
|
|
Usage:
|
|
sudo scripts/ethercat/stop_ethercat.sh [iface] [--restore-network]
|
|
|
|
Examples:
|
|
sudo scripts/ethercat/stop_ethercat.sh eno1
|
|
sudo scripts/ethercat/stop_ethercat.sh eno1 --restore-network
|
|
|
|
Environment:
|
|
IGH_ROOT=... Override bundled IgH install path.
|
|
ETHERCAT_CONF=... Override ethercatctl config path.
|
|
USAGE
|
|
}
|
|
|
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
if [[ "$(id -u)" -ne 0 ]]; then
|
|
echo "error: please run with sudo." >&2
|
|
exit 1
|
|
fi
|
|
|
|
IFACE="eno1"
|
|
RESTORE_NETWORK="false"
|
|
|
|
for arg in "$@"; do
|
|
case "${arg}" in
|
|
--restore-network)
|
|
RESTORE_NETWORK="true"
|
|
;;
|
|
-*)
|
|
echo "error: unknown option: ${arg}" >&2
|
|
usage >&2
|
|
exit 1
|
|
;;
|
|
*)
|
|
IFACE="${arg}"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
IGH_ROOT="${IGH_ROOT:-${REPO_ROOT}/dependency/x86/third_party/ethercat/v1.7.0}"
|
|
ETHERCAT_CONF="${ETHERCAT_CONF:-${IGH_ROOT}/etc/ethercat.conf}"
|
|
ETHERCATCTL="${IGH_ROOT}/sbin/ethercatctl"
|
|
|
|
if [[ ! -x "${ETHERCATCTL}" ]]; then
|
|
echo "error: ethercatctl not found: ${ETHERCATCTL}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
"${ETHERCATCTL}" -c "${ETHERCAT_CONF}" stop
|
|
|
|
if [[ "${RESTORE_NETWORK}" == "true" ]]; then
|
|
ip link set "${IFACE}" up
|
|
if command -v nmcli >/dev/null 2>&1; then
|
|
nmcli device connect "${IFACE}" || true
|
|
fi
|
|
echo "Stopped EtherCAT and requested normal network restore on ${IFACE}."
|
|
else
|
|
echo "Stopped EtherCAT. Normal network restore skipped."
|
|
echo "Use '--restore-network' if this interface should return to NetworkManager."
|
|
fi
|