#!/bin/bash lockdir="/dswork.lock" if mkdir "$lockdir" then # Successfully acquired lock for i in $(ls /sys/bus/usb/drivers/uvcvideo/|grep :) ; do echo $i >/sys/bus/usb/drivers/uvcvideo/unbind echo $i >/sys/bus/usb/drivers/uvcvideo/bind echo "Reseting" $i done sleep 2 rm -rf "$lockdir" else # Cannot acquire lock. Aborting. exit 0 fi