Utilisation des options --user --password avec les commandes oneuser

ref #17203 @10m
This commit is contained in:
Philippe Caseiro 2016-09-23 13:53:23 +02:00
parent bb18ec0520
commit 5fea856bec
1 changed files with 26 additions and 3 deletions

View File

@ -1,12 +1,35 @@
#!/bin/bash
function error()
{
MSG=${1}
echo "[ERROR][${MSG}]"
exit 1
}
function get_user_home()
{
HOMEDIR=$(getent passwd ${1} | cut -d ':' -f 6)
echo ${HOMEDIR}
}
function get_one_auth()
{
CMD="cat"
HOME=$(get_user_home oneadmin)
FILE="${HOME}/.one/one_auth"
${CMD} ${FILE}
}
if [ "$1" != 'instance' ];then
exit 0
fi
USER=eoleone
AUTH=$(get_one_auth)
if oneuser show $USER &> /dev/null
if oneuser show $USER --user ${AUTH%:*} --password ${AUTH#*:} &> /dev/null
then
echo "$USER existe déjà, abandon."
exit 0
@ -27,8 +50,8 @@ do
echo
[ $newpass1 != $newpass2 ] && echo "Les mots de passe ne correspondent pas, recommencez"
done
oneuser create $USER $newpass1
oneuser create $USER $newpass1 --user ${AUTH%:*} --password ${AUTH#*:}
echo
echo "Inscription de l'utilisateur $USER dans le groupe oneadmin"
echo
oneuser chgrp $USER oneadmin
oneuser chgrp $USER oneadmin --user ${AUTH%:*} --password ${AUTH#*:}