From 5de445c9377905bc637e05bbb85aebc87ee24bd1 Mon Sep 17 00:00:00 2001 From: Jocelyn Le Sage Date: Mon, 15 May 2017 11:13:51 -0400 Subject: [PATCH] Adjusted nice permission check to be compatible with debian. --- rootfs/etc/cont-init.d/00-app-niceness.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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."