aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-10-27 14:00:18 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-10-27 14:00:18 -0200
commit601eb9c3e9bd140745d62e9931bb5c2a8be85724 (patch)
treeeb2c275dba36208753097372ccbbb20eb2d1e761
parent536c33213619751b41519049ac2d12a29ab553ff (diff)
downloadhydra-601eb9c3e9bd140745d62e9931bb5c2a8be85724.tar.gz
hydra-601eb9c3e9bd140745d62e9931bb5c2a8be85724.tar.bz2
Usb: sudo config
-rwxr-xr-xshare/hydractl/usb-disable9
1 files changed, 7 insertions, 2 deletions
diff --git a/share/hydractl/usb-disable b/share/hydractl/usb-disable
index d281f70..0ee2471 100755
--- a/share/hydractl/usb-disable
+++ b/share/hydractl/usb-disable
@@ -9,14 +9,19 @@
# Parameters
BASENAME="`basename $0`"
+# Sudo config
+if [ "`whoami`" != 'root' ]; then
+ SUDO="sudo"
+fi
+
# Set hotplug state
function usb_set_state {
echo "Applying at /sys/module/usbcore/parameters/authorized_default..."
- sudo su -c "echo $1 > /sys/module/usbcore/parameters/authorized_default"
+ $SUDO su -c "echo $1 > /sys/module/usbcore/parameters/authorized_default"
for bus in /sys/bus/usb/devices/usb*; do
echo "Applying at ${bus}/authorized_default..."
- sudo su -c "echo $1 > ${bus}/authorized_default"
+ $SUDO su -c "echo $1 > ${bus}/authorized_default"
done
}