summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xusbmon-setperms7
1 files changed, 6 insertions, 1 deletions
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"