aboutsummaryrefslogtreecommitdiff
path: root/fixrtcaps
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2015-04-08 03:18:53 -0400
committerB. Watson <yalhcru@gmail.com>2015-04-08 03:18:53 -0400
commit122f3c401f23f84799802c7b9667bda222646487 (patch)
treebc77cc44c516eac71b2d6490574fd32a5b5efd65 /fixrtcaps
downloadmisc-scripts-122f3c401f23f84799802c7b9667bda222646487.tar.gz
initial commit
Diffstat (limited to 'fixrtcaps')
-rwxr-xr-xfixrtcaps36
1 files changed, 36 insertions, 0 deletions
diff --git a/fixrtcaps b/fixrtcaps
new file mode 100755
index 0000000..ba7978d
--- /dev/null
+++ b/fixrtcaps
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Released into the public domain by B. Watson <yalhcru@gmail.com>
+# No warranty of any kind. If it breaks, you get to keep both pieces.
+
+BINDIRS="/usr/bin /usr/local/bin"
+
+fix_rt_caps() {
+ echo "Looking for JACK binaries in $1"
+ cd "$1" || return
+ find . -type f | xargs file | grep ELF.*executable | cut -d: -f1 | while read bin; do
+ if ldd $bin 2>/dev/null | grep -q libjack; then
+ echo "setting caps on $( readlink -f $1/$bin )"
+ /sbin/setcap cap_ipc_lock,cap_sys_nice=ep $bin
+ fi
+ done
+}
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ cat <<EOF
+$( basename $0 ) v1.0: set POSIX realtime priority and unlimited memory lock
+capabilities on JACK-using binaries.
+
+Usage: $( basename $0 ) <optional list of directories>
+
+With no arguments, the default list of directories is:
+ $BINDIRS
+EOF
+ exit 0
+fi
+
+if [ $# = 0 ]; then
+ set $BINDIRS
+fi
+
+for dir in "$@"; do fix_rt_caps $dir; done