create-cracklib-dict 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. usage() {
  3. cat <<-EOF
  4. Usage: create-cracklib-dict [options] wordlist ...
  5. This script takes one or more word list files as arguments
  6. and converts them into cracklib dictionaries for use
  7. by password checking programs. The results are placed in
  8. the default compiled-in dictionary location.
  9. If you wish to store the dictionary in a different location,
  10. use the cracklib-format and cracklib-packer commands directly.
  11. Options:
  12. -o, --output <file> Alternative output file for cracklib-packer
  13. -h, --help This help output
  14. Example:
  15. create-cracklib-dict /usr/share/words
  16. EOF
  17. if [ -n "$*" ] ; then
  18. echo 1>&2
  19. echo "Error: $*" 1>&2
  20. exit 1
  21. else
  22. exit 0
  23. fi
  24. }
  25. output=""
  26. while [ -n "$1" ] ; do
  27. case $1 in
  28. -o|--output) output=$2; shift;;
  29. -h|--help) usage;;
  30. --) break;;
  31. -*) usage "unknown option '$*'";;
  32. *) break;;
  33. esac
  34. shift
  35. done
  36. [ -z "$*" ] && usage
  37. exec cracklib-format "$@" | cracklib-packer ${output}