tst-pam_motd1.sh 716 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. TST_DIR="tst-pam_motd1.d"
  3. function tst_cleanup() {
  4. rm -rf "${TST_DIR}"
  5. rm -f tst-pam_motd1.out
  6. }
  7. mkdir -p ${TST_DIR}
  8. mkdir -p ${TST_DIR}/etc/motd.d
  9. # Verify the case of single motd and motd.d directory works
  10. echo "motd: /etc/motd" > ${TST_DIR}/etc/motd
  11. echo "motd: /etc/motd.d/test" > ${TST_DIR}/etc/motd.d/test
  12. ./tst-pam_motd tst-pam_motd1 > tst-pam_motd1.out
  13. RET=$?
  14. motd_to_show_output=$(cat tst-pam_motd1.out | grep "motd: /etc/motd")
  15. if [ -z "${motd_to_show_output}" ];
  16. then
  17. tst_cleanup
  18. exit 1
  19. fi
  20. motd_dir_to_show_output=$(cat tst-pam_motd1.out | grep "motd: /etc/motd.d/test")
  21. if [ -z "${motd_dir_to_show_output}" ];
  22. then
  23. tst_cleanup
  24. exit 1
  25. fi
  26. tst_cleanup
  27. exit $RET