usbmon-setperms: fix when group does not match user

This commit is contained in:
Peter Wu
2013-08-25 16:29:50 +02:00
parent 7e7bbbdabd
commit be1199bc79

View File

@@ -6,6 +6,11 @@ if [ "$USER" = "root" ]; then
exit 1 exit 1
fi fi
GROUP="$(id -g)"
if [ $GROUP = 0 ]; then
GROUP="$(id -g "$USER")"
fi
if [ ! -e /dev/usbmon0 ]; then if [ ! -e /dev/usbmon0 ]; then
echo "Attempting to modprobe usbmon..." echo "Attempting to modprobe usbmon..."
sudo modprobe -v usbmon sudo modprobe -v usbmon
@@ -21,7 +26,7 @@ echo Found devices: $usbmons
if [ -n "$usbmons" ]; then if [ -n "$usbmons" ]; then
echo "Attempting to change permissions..." echo "Attempting to change permissions..."
sudo chgrp -v $USER $usbmons sudo chgrp -v $GROUP $usbmons
sudo chmod -v g+rw $usbmons sudo chmod -v g+rw $usbmons
else else
echo "No devices found" echo "No devices found"