47 lines
1.4 KiB
Plaintext
Executable File
47 lines
1.4 KiB
Plaintext
Executable File
##----------------------------------------------------------------------------
|
|
## Script : gen-mdp.lib
|
|
## Module Puppet : gnc-script_core_dtsi
|
|
## Auteur : Emmanuel Confrere
|
|
## Date : 10-02-2016
|
|
## Version : 1.0.0
|
|
## Objet : Genration d un mots depasse aleatoire
|
|
##
|
|
## Fonction : fct_gen_mdp
|
|
##
|
|
## Detail :
|
|
##
|
|
# ----------------------------------------------------------------------------
|
|
# Mise a jour :
|
|
# 1.0.0 10-02-2016 - Emmanuel Confrere - Creation : Reprise du script du socle Oracle
|
|
##----------------------------------------------------------------------------
|
|
|
|
function fct_gen_mdp
|
|
{
|
|
local L_CARACTERES="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
local L_CHIFFRES="1234567890"
|
|
local L_SPECCAR="-=:#+_"
|
|
local L_MDP=""
|
|
local L_TMP=""
|
|
local L_CPT=1
|
|
local L_LONGUEUR=9
|
|
local L_SIMPLE="non"
|
|
|
|
[ "$1" = "-ns" ] && L_SPECCAR=""
|
|
[ -z "$1" -a "$1" != "-ns" ] && L_SIMPLE="oui"
|
|
|
|
L_MDP=${L_CARACTERES:$(( $RANDOM % ${#L_CARACTERES} )):1}
|
|
L_TMP="${L_CARACTERES}${L_SPECCAR}${L_CHIFFRES}${L_SPECCAR}${L_CHIFFRES}${L_SPECCAR}${L_CHIFFRES}"
|
|
if [ -z "$1" -a "$1" != "-ns" ]
|
|
then
|
|
while [ ${L_CPT} -le ${L_LONGUEUR} ]
|
|
do
|
|
L_MDP="${L_MDP}${L_TMP:$(( $RANDOM % ${#L_TMP} )):1}"
|
|
((L_CPT++))
|
|
done
|
|
else
|
|
L_MDP=`echo $1|md5sum|sed 's/ *//g;s/-$//;s/[0-9]*\([a-f][a-f,0-9]*\)/\1/'|cut -c1-9`
|
|
fi
|
|
echo ${L_MDP}
|
|
}
|
|
|
|
typeset -Ffx fct_gen_mdp |