#!/bin/bash
# /usr/sbin/usbip-manager-setup — the root-side setup of the Ubuntu package (L15). Usage (root):
#   usbip-manager-setup permissions            sudoers rules so the GUI can run usbip / modprobe without a password
#   usbip-manager-setup server <client-ip|cidr>…   usbipd + auto-export; only the listed clients may reach TCP 3240
#   usbip-manager-setup client <server-ip>     auto-attach service (systemd)
#   usbip-manager-setup uninstall              remove services, rules and sudoers entries made above
# Installing the .deb changes none of this: sharing devices and opening TCP 3240 is the user's decision.
# The scripts are the repo's own, installed in /usr/share/usbip-manager (install.sh, setup_permissions.sh).
# 2026-11-06 · added (L15) · wiki: http://localhost:3000/wiki/auto/usbip#l15
set -euo pipefail
D=/usr/share/usbip-manager
case "${1:-}" in
  permissions) shift; exec "$D/setup_permissions.sh" "$@" ;;
  server|client) exec "$D/install.sh" "$@" ;;
  uninstall) "$D/install.sh" uninstall; rm -f /etc/sudoers.d/usbip-manager; echo "sudoers rules removed" ;;
  *) sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;
esac
