check-limits.sh 1.0KB

123456789101112131415161718192021
  1. #!/bin/bash
  2. case $1 in
  3. core-dumps)
  4. if sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/security/limits.conf | grep "hard.*core";then
  5. if [ $(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/security/limits.conf | grep "hard.*core" | awk -F 'core' '{print $2}' | sed 's/\ *//g') -ne 0 ];then
  6. exit 1
  7. fi
  8. else
  9. exit 1
  10. fi
  11. ;;
  12. maxlogins)
  13. if sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/security/limits.conf | grep "maxlogins";then
  14. if [ $(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/security/limits.conf | grep "maxlogins" | awk -F 'maxlogins' '{print $2}' | sed 's/\ *//g') -ne 2 ];then
  15. exit 1
  16. fi
  17. else
  18. exit 1
  19. fi
  20. ;;
  21. esac