diff --git a/lib/aaa_errors.sh b/lib/aaa_errors.sh index 6595200..d9cea2e 100644 --- a/lib/aaa_errors.sh +++ b/lib/aaa_errors.sh @@ -86,10 +86,19 @@ function backtrace # Execute command outside of error control, echoes ouput error code noerror() { + if [[ $1 == "--noout" ]]; then + local noout=true + shift + fi + set +o errexit trap - ERR - $@ + if [[ -n $noout ]]; then + $@ > /dev/null 2>&1 + else + $@ + fi local code=$? trap "error ${LINENO}" ERR diff --git a/modules/authnz.sh b/modules/authnz.sh index fbb6a6f..73ec9ab 100644 --- a/modules/authnz.sh +++ b/modules/authnz.sh @@ -13,7 +13,7 @@ # * LOCAL_USERS: List of local users to create # ------------------------------------------------------------------------------ -export VER_authnz=0.1.1 +export VER_authnz=0.1.2 # Users (from Ldap) add_remote_user() @@ -27,7 +27,11 @@ add_remote_user() # Create a local user create_user() { - useradd -Um $1 + if [[ $(noerror --noouut id $1) != 0 ]]; then + useradd -Um $1 + else + prnt W "L'utilisateur $1 existe déjà. Rien à faire..." + fi } # Authentication