summaryrefslogtreecommitdiff
path: root/localresetpasswdexpiry
blob: 6d01eb23f7ab3f96c3c311601e708c24d5389c05 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/bin/localresetpasswdexpiry
  4. # Copyright 2006 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localresetpasswdexpiry,v 1.1 2006-08-31 22:51:03 jonas Exp $
  7. #
  8. # (re)set password expiry through sudo
  9. #
  10. # TODO: Check for bad arguments
  11. # TODO: Use getopts to offer help
  12. # TODO: Support overriding options in /etc/local file
  13. #
  14. set -e
  15. pass_expire=365
  16. pass_warn=14
  17. pass_lastday="`date --date='11 months ago' '+%F'`"
  18. verbose=1
  19. #simulate=true
  20. interactive=0
  21. # echo something, but only if in verbose mode
  22. vecho() {
  23. test -n "$verbose" && echo "$@" >&2
  24. }
  25. u=$1
  26. shift
  27. vecho -n "Set password aging for $u (expire: $pass_expire, warn: $pass_warn, lastday: $pass_lastday)..."
  28. eval $simulate sudo "/usr/bin/chage -M$pass_expire -W$pass_warn -d$pass_lastday \"$u\""
  29. vecho " Done!"