Skip to content

Instantly share code, notes, and snippets.

@raultm
Last active January 14, 2019 07:55
Show Gist options
  • Save raultm/b5e65719cd302fcbb28e74a18ffdde4e to your computer and use it in GitHub Desktop.
Save raultm/b5e65719cd302fcbb28e74a18ffdde4e to your computer and use it in GitHub Desktop.
#!/bin/bash
INCREMENTDIR=`date +%Y-%m-%d`
LOGFILE=/root/usb/$INCREMENTDIR
attach_storage()
{
set `lsusb -d ${ID_VENDOR_ID}:${ID_MODEL_ID}| sed 's/:.*//g'`
while [ ! -z "$1" ]; do
case $1 in
Bus) shift
busdevice="$1"
;;
Device) shift
busdevice=${busdevice}"/$1"
;;
esac
shift
done
if [ ! -z "$busdevice" ]; then
address=$(VBoxManage list usbhost | grep "Address:" | grep $busdevice | sed -e 's/Address://' -e 's/^[ \t]*//')
if [ ! -z "$address" ]; then
echo "VBoxManage controlvm WINDOWS usbattach $address" >> $LOGFILE
su USUARIO -c "VBoxManage controlvm NOMBRE_MAQUINA_VIRTUAL usbattach $address"
fi
fi
}
echo "Montando USB" >> $LOGFILE
for var in "$@"
do
echo "$var" >> $LOGFILE
done
case $DEVNAME in
/dev/sd[a-z])
attach_storage;
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment