58 lines
1.2 KiB
Bash
Executable File
58 lines
1.2 KiB
Bash
Executable File
#!/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 --user ${AUTH%:*} --password ${AUTH#*:} &> /dev/null
|
|
then
|
|
echo "$USER existe déjà, abandon."
|
|
exit 0
|
|
fi
|
|
|
|
echo
|
|
echo "Initialisation du mot de passe pour l'utilisateur \"$USER\" pour l'accès à l'interface Web Sunstone"
|
|
echo
|
|
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
|
|
oneuser create $USER $newpass1 --user ${AUTH%:*} --password ${AUTH#*:}
|
|
echo
|
|
echo "Inscription de l'utilisateur $USER dans le groupe oneadmin"
|
|
echo
|
|
oneuser chgrp $USER oneadmin --user ${AUTH%:*} --password ${AUTH#*:}
|