| OLD | NEW |
| (Empty) |
| 1 #!/bin/sh | |
| 2 | |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 # | |
| 7 # Wrapper for the USB-over-IP server control program from | |
| 8 # www.incentivespro.com that starts the server when necessary. | |
| 9 | |
| 10 set -e | |
| 11 | |
| 12 RUNFILE=/var/run/usbsrvd | |
| 13 | |
| 14 SCRIPT_DIR="$(dirname "$0")" | |
| 15 EXE_DIR="${SCRIPT_DIR}" | |
| 16 | |
| 17 # If installed in mod_for_test, this script lives in /usr/local/bin, | |
| 18 # but if installed with gmerge, it lives in /usr/bin. Search | |
| 19 # ../local/bin if necessary. | |
| 20 if [ ! -f "${SCRIPT_DIR}/usbsrv.real" -a \ | |
| 21 -f "${SCRIPT_DIR}/../local/bin/usbsrv.real" ]; then | |
| 22 EXE_DIR="${SCRIPT_DIR}/../local/bin" | |
| 23 fi | |
| 24 | |
| 25 USBSRV_REAL="${EXE_DIR}/usbsrv.real" | |
| 26 USBSRVD="${EXE_DIR}/usbsrvd" | |
| 27 | |
| 28 log() { | |
| 29 echo "$@" | tee /dev/stderr | logger -t usbsrv-wrapper | |
| 30 } | |
| 31 | |
| 32 | |
| 33 if [ ! -f "${USBSRV_REAL}" ] ; then | |
| 34 # We don't want to install this without explicit action | |
| 35 log 'USB-over-IP script is not installed. Run "install-usbsrv" to install' | |
| 36 exit 1 | |
| 37 fi | |
| 38 | |
| 39 | |
| 40 if [ ! -f ${RUNFILE} ] ; then | |
| 41 # For various reasons, we don't have an init script, so we start the | |
| 42 # server from this wrapper if needed | |
| 43 log "Starting USB-over-IP server..." | |
| 44 sudo modprobe tusbd | |
| 45 sudo iptables -A INPUT -p tcp --dport 32032 -j ACCEPT | |
| 46 sudo ${USBSRVD} | |
| 47 sleep 1 # Allow server to stabilize since we don't have a good event to wait o
n | |
| 48 sudo touch ${RUNFILE} | |
| 49 log "USB-over-IP server started" | |
| 50 fi | |
| 51 | |
| 52 exec sudo "${USBSRV_REAL}" "$@" | |
| OLD | NEW |