#!/bin/sh DAEMON=usbip DAEMON_LONG_NAME="USB-IP" DAEMON_BIN=usbipd . /etc/init.d/modlibrc share() { local USBIP_BUSID="" if [ "$USBIP_ALL" == "yes" ]; then USBIP_BUSID="$USBIP_BUSID $(usbip_bind_driver --list | grep -vE " hub$| usb-storage$" | sed -n 's/^ *\([0-9\.-]*\)\:.*/\1/p')" fi if [ "$USBIP_STORAGES" == "yes" ]; then USBIP_BUSID="$USBIP_BUSID $(usbip_bind_driver --list | sed -n 's/^ *\([0-9\.-]*\)\:.* usb-storage$/\1/p')" fi if [ "$USBIP_HUBS" == "yes" ]; then USBIP_BUSID="$USBIP_BUSID $(usbip_bind_driver --list | sed -n 's/^ *\([0-9\.-]*\)\:.* hub$/\1/p')" fi local USBIP_CUSTOM_CLEANED="$(echo $USBIP_CUSTOM | grep -vE '^ *#|^ *;|^ *$')" for USBIP_CUSTOM_CURRENT in $USBIP_CUSTOM_CLEANED; do USBIP_BUSID="$USBIP_BUSID $(usbip_bind_driver --list | grep -i "($USBIP_CUSTOM_CURRENT)$" | sed 's/ - busid //;s/ .*//g')" done local USBIP_BUSID="$(echo $USBIP_BUSID | tr ' ' '\n' | sort -u)" for USBIP_BUSID_CURRENT in $USBIP_BUSID; do usbip_bind_driver --usbip $USBIP_BUSID_CURRENT >/dev/null 2>&1 done } config() { modprobe usbip modprobe usbip_common_mod } start() { modlib_startdaemon $DAEMON_BIN -D 2>/dev/null share } reload() { share } case $1 in ""|load) modreg cgi $DAEMON "$DAEMON_LONG_NAME" modreg daemon $DAEMON modlib_start $USBIP_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi $DAEMON modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; reload) modlib_reload ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|reload|status]" 1>&2 exit 1 ;; esac exit 0