| echo "Usage: $0 <remoteip | --use-storage-box> <isostream options...>" >&2 |
| echo ' $ISOSTREAM_DISABLE_IF_PORT: if set, stops automatically if the' >&2 |
| echo " given port is in use." >&2 |
| [ -n "$ISOSTREAM_DISABLE_IF_PORT" ] && |
| [ "$ISOSTREAM_DISABLE_IF_PORT" != "0" ] && |
| netstat -an | grep -q ":$ISOSTREAM_DISABLE_IF_PORT .*ESTABLISHED" |
| if [ "$remote" = "--use-storage-box" ]; then |
| STORAGE_BOX_NAME=gfiberstorage.local |
| echo "$0: use-storage-box: trying to find server: $STORAGE_BOX_NAME" >&2 |
| while [ -z "$remote" ]; do |
| out=$(avahi-resolve -6n "$STORAGE_BOX_NAME") |
| if [ "$?" -ne "0" ]; then |
| remote=$(echo "$out" | head -n 1 | cut -f 2) |
| echo "$0: use-storage-box: found a server: $remote" >&2 |
| echo "pausing test because port $ISOSTREAM_DISABLE_IF_PORT open" >&2 |
| echo "Starting: isostream $* '$remote'" >&2 |
| isostream "$@" "$remote" & |
| ) 2>&1 | tee /proc/self/fd/5 | logos isostream # Send output to isostream, and also fd #5 so it ends up back on stdout |
| ) 5>&1 # make fd #5 a copy of the original stdout |