diff --git a/rootfs/etc/cont-init.d/00-app-niceness.sh b/rootfs/etc/cont-init.d/00-app-niceness.sh index ded62b0..0c70631 100755 --- a/rootfs/etc/cont-init.d/00-app-niceness.sh +++ b/rootfs/etc/cont-init.d/00-app-niceness.sh @@ -10,9 +10,11 @@ set -u # Treat unset variables as an error. APP_NICE_CMD=' ' if [ "${APP_NICENESS:-UNSET}" != "UNSET" ]; then - APP_NICE_CMD="nice -n $APP_NICENESS" + APP_NICE_CMD="$(which nice) -n $APP_NICENESS" - if ! $APP_NICE_CMD echo &> /dev/null; then + # NOTE: On debian systems, nice always has an exit code of `0`, even when + # permission is denied. Look for the error message instead. + if [ "$($APP_NICE_CMD true 2>&1)" != "" ]; then echo "ERROR: Permission denied to set application's niceness to" \ "$APP_NICENESS. Make sure the container is started with the" \ "--cap-add=SYS_NICE option."