2016-04-21 15:30:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-09-23 13:53:23 +02:00
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-21 15:30:52 +02:00
|
|
|
if [ "$1" != 'instance' ];then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
USER=eoleone
|
2016-09-23 13:53:23 +02:00
|
|
|
AUTH=$(get_one_auth)
|
2016-05-10 14:01:55 +02:00
|
|
|
|
2016-09-23 13:53:23 +02:00
|
|
|
if oneuser show $USER --user ${AUTH%:*} --password ${AUTH#*:} &> /dev/null
|
2016-04-21 15:30:52 +02:00
|
|
|
then
|
|
|
|
echo "$USER existe déjà, abandon."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-05-10 14:01:55 +02:00
|
|
|
echo
|
2016-04-21 15:30:52 +02:00
|
|
|
echo "Initialisation du mot de passe pour l'utilisateur \"$USER\" pour l'accès à l'interface Web Sunstone"
|
2016-05-10 14:01:55 +02:00
|
|
|
echo
|
2016-04-21 15:30:52 +02:00
|
|
|
newpass1=a
|
|
|
|
newpass2=b
|
|
|
|
while [ $newpass1 != $newpass2 ]
|
|
|
|
do
|
|
|
|
echo -n "Entrez le nouveau mot de passe : "
|
|
|
|
read -s newpass1
|
|
|
|
echo
|
|
|
|
echo -n "Retapez le nouveau mot de passe : "
|
|
|
|
read -s newpass2
|
|
|
|
echo
|
|
|
|
[ $newpass1 != $newpass2 ] && echo "Les mots de passe ne correspondent pas, recommencez"
|
|
|
|
done
|
2016-09-23 13:53:23 +02:00
|
|
|
oneuser create $USER $newpass1 --user ${AUTH%:*} --password ${AUTH#*:}
|
2016-05-10 14:01:55 +02:00
|
|
|
echo
|
2016-04-21 15:30:52 +02:00
|
|
|
echo "Inscription de l'utilisateur $USER dans le groupe oneadmin"
|
2016-05-10 14:01:55 +02:00
|
|
|
echo
|
2016-09-23 13:53:23 +02:00
|
|
|
oneuser chgrp $USER oneadmin --user ${AUTH%:*} --password ${AUTH#*:}
|