2014-02-25 10:28:32 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
2023-01-25 17:14:03 +04:00
|
|
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
|
|
|
urequire password
|
2014-02-25 10:28:32 +04:00
|
|
|
|
|
|
|
function display_help() {
|
|
|
|
uecho "$scriptname: générer un mot de passe au hasard
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$scriptname [options]
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-l, --len LEN
|
|
|
|
Spécifier le nombre de caractères du mot de passe généré
|
|
|
|
-U, --upper COUNT
|
|
|
|
-L, --lower COUNT
|
|
|
|
-A, --alpha COUNT
|
|
|
|
-N, --number COUNT
|
|
|
|
-S, --symbol COUNT
|
|
|
|
-B, --special COUNT
|
|
|
|
Spécifier le nombre minimum de chaque classe de caractère"
|
|
|
|
}
|
|
|
|
|
|
|
|
len=
|
|
|
|
upper=
|
|
|
|
lower=
|
|
|
|
alpha=
|
|
|
|
number=
|
|
|
|
symbol=
|
|
|
|
special=
|
|
|
|
parse_opts "${PRETTYOPTS[@]}" \
|
|
|
|
--help '$exit_with display_help' \
|
|
|
|
-l:,--len: len= \
|
|
|
|
-U:,--upper: upper= \
|
|
|
|
-L:,--lower: lower= \
|
|
|
|
-A:,--alpha: alpha= \
|
|
|
|
-N:,--number: number= \
|
|
|
|
-S:,--symbol: symbol= \
|
|
|
|
-B:,--special: special= \
|
|
|
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
|
|
|
|
2014-02-25 10:40:01 +04:00
|
|
|
[ -n "$len" ] || len="$GENPASS_LEN"
|
|
|
|
[ -n "$upper" ] || upper="${GENPASS_COUNTS[0]}"
|
|
|
|
[ -n "$lower" ] || lower="${GENPASS_COUNTS[1]}"
|
|
|
|
[ -n "$alpha" ] || alpha="${GENPASS_COUNTS[2]}"
|
|
|
|
[ -n "$number" ] || number="${GENPASS_COUNTS[3]}"
|
|
|
|
[ -n "$symbol" ] || symbol="${GENPASS_COUNTS[4]}"
|
|
|
|
[ -n "$special" ] || special="${GENPASS_COUNTS[5]}"
|
|
|
|
|
|
|
|
GENPASS_LEN="$len"
|
|
|
|
GENPASS_COUNTS=("$upper" "$lower" "$alpha" "$number" "$symbol" "$special")
|
|
|
|
genpass
|