Skip to content

Instantly share code, notes, and snippets.

@johannrichard
Last active March 16, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johannrichard/f2aaf07966421d3152bb5e22ea29deb3 to your computer and use it in GitHub Desktop.
Save johannrichard/f2aaf07966421d3152bb5e22ea29deb3 to your computer and use it in GitHub Desktop.
VirtualHere USB Service (Download Server from https://www.virtualhere.com/usb_server_software)
#!/bin/sh
# This little script downloads the VirtualHere USB client and sets up a service
# on arm-based systems
VHUSB_URL="https://virtualhere.com/sites/default/files/usbserver/vhusbdarm"
VHUSB_BINARY="/usr/local/bin/vhusbdarm"
VHUSB_SERVICE="/etc/systemd/system/vhusb.service"
if [[ `uname -m` == *"arm"* ]]
then
echo "It's an ARM architecture!";
if [ ! -e "$VHUSB_BINARY" ]; then
echo "Attemtping to get root permissions to save 'vhusbdarm' to your system and downloading server and service script"
sudo wget -o "$VHUSB_BINARY" $VHUSB_URL
if [ -e "$VHUSB_BINARY" ]; then
echo "VirtualHere Binary successfully downloaded and saved as $VHUSB_BINARY. Attemting to install service at $VHUSB_SERVICE"
sudo /bin/cat <<EOM >$VHUSB_SERVICE
[Unit]
Description=VirtualHere USB Client
Requires=avahi-daemon.service
After=avahi-daemon.service
[Service]
ExecStart=/usr/local/bin/vhusbdarm -b
Type=forking
[Install]
WantedBy=default.target
EOM
else
echo "VirtualHere Service binary not found at $VHUSB_BINARY. Abort."
exit 1
fi
else
echo "Binary already exists. Abort."
exit 1
fi
else
echo "We're not on ARM architecture. Abort."
exit 1
fi
[Unit]
Description=VirtualHere USB Client
[Service]
ExecStart=/usr/local/bin/vhusbdarm -b
Type=forking
[Install]
WantedBy=default.target
@johannrichard
Copy link
Author

johannrichard commented Jul 10, 2016

Use this service script to create a systemd service for VirtualHub USB (e.g. on a Raspberry Pi) to access USB devices remotely. You need to have the corrcet binary installed in /usr/local/bin (bhusbdarm for generic arm version) or adapt the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment