From be1199bc79a8d82a4a4f89a405e665a10ea7e5c4 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 25 Aug 2013 16:29:50 +0200 Subject: usbmon-setperms: fix when group does not match user --- usbmon-setperms | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'usbmon-setperms') diff --git a/usbmon-setperms b/usbmon-setperms index d2cc893..3097c78 100755 --- a/usbmon-setperms +++ b/usbmon-setperms @@ -6,6 +6,11 @@ if [ "$USER" = "root" ]; then exit 1 fi +GROUP="$(id -g)" +if [ $GROUP = 0 ]; then + GROUP="$(id -g "$USER")" +fi + if [ ! -e /dev/usbmon0 ]; then echo "Attempting to modprobe usbmon..." sudo modprobe -v usbmon @@ -21,7 +26,7 @@ echo Found devices: $usbmons if [ -n "$usbmons" ]; then echo "Attempting to change permissions..." - sudo chgrp -v $USER $usbmons + sudo chgrp -v $GROUP $usbmons sudo chmod -v g+rw $usbmons else echo "No devices found" -- cgit v1.2.1