#!/bin/bash # Released into the public domain by B. Watson # 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 < 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