member.sh 896 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. echo "---------------------------------------------------"
  3. echo "USERNAME EXP DATE STATUS"
  4. echo "---------------------------------------------------"
  5. while read expired
  6. do
  7. AKUN="$(echo $expired | cut -d: -f1)"
  8. ID="$(echo $expired | grep -v nobody | cut -d: -f3)"
  9. exp="$(chage -l $AKUN | grep "Account expires" | awk -F": " '{print $2}')"
  10. status="$(passwd -S $AKUN | awk '{print $2}' )"
  11. if [[ $ID -ge 1000 ]]; then
  12. if [[ "$status" = "L" ]]; then
  13. printf "%-17s %2s %-17s %2s \n" "$AKUN" "$exp " "${RED}LOCKED${NORMAL}"
  14. else
  15. printf "%-17s %2s %-17s %2s \n" "$AKUN" "$exp " "${GREEN}UNLOCKED${NORMAL}"
  16. fi
  17. fi
  18. done < /etc/passwd
  19. JUMLAH="$(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd | wc -l)"
  20. echo "---------------------------------------------------"
  21. echo "Account number: $JUMLAH user"
  22. echo "---------------------------------------------------"