summaryrefslogtreecommitdiff
path: root/localresetpasswdexpiry
blob: 93b26e7d5a8322a18fa03d13d9740aa65d041a8e (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. sudo=sudo
  28. [ "$(id -u)" -ne 0 ] || sudo=
  29. vecho -n "Set password aging for $u (expire: $pass_expire, warn: $pass_warn, lastday: $pass_lastday)..."
  30. eval $simulate $sudo "/usr/bin/chage -M$pass_expire -W$pass_warn -d$pass_lastday \"$u\""
  31. vecho " Done!"