summaryrefslogtreecommitdiff
path: root/usbmon-setperms
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-25 16:29:50 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-08-25 16:29:50 +0200
commitbe1199bc79a8d82a4a4f89a405e665a10ea7e5c4 (patch)
tree18e298999539b140792ab1ab0a18bb134f648076 /usbmon-setperms
parent7e7bbbdabde14d46d8346c9f8f68c39130ed1bc5 (diff)
downloadltunify-be1199bc79a8d82a4a4f89a405e665a10ea7e5c4.tar.gz
usbmon-setperms: fix when group does not match user
Diffstat (limited to 'usbmon-setperms')
-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"