Skip to content
Snippets Groups Projects
Commit c5b96bf1 authored by Thiago Abdo's avatar Thiago Abdo
Browse files

Finaliza hd_drive


Signed-off-by: default avatarThiago Abdo <tja14@inf.ufpr.br>
parent 2d429f7c
No related branches found
No related tags found
No related merge requests found
......@@ -195,42 +195,49 @@ function usb_drive {
}
function hd_drive {
mount_path="/home"
create_dir
# crete the dir /home/openslx and config files
if [ ! -d "/home/openslx" ]; then
mkdir -p /home/openslx/
fi
if [ ! -e "/home/openslx/config" ]; then
touch /home/openslx/config
fi
if [ ! -e "/home/openslx/log" ]; then
touch /home/openslx/log
fi
#get the username
new_user=$( dialog --stdout --inputbox 'Digite o nome de usuário:' 0 0 )
check_user_name=` cat "$mount_path"/Openslx/log | grep -w "$new_user"`
while [[ -n $check_user_name ]];
do
new_user=$( dialog --stdout --inputbox 'Nome de usuário já existente. Digite outro nome de usuário:' 0 0 )
check_user_name=`cat "$mount_path"/Openslx/log | grep -w "$new_user"`
done
read_user_pass
#get the password
pass=$( dialog --stdout --passwordbox 'Por favor, digite a senha:' 0 0 )
check_pass=$( dialog --stdout --passwordbox 'Por favor, confirme a senha:' 0 0 )
while [ "$pass" != "$check_pass" ];
do
user_id=cat /etc/passwd | cut -d: -f3 | grep -e 2....$ | sort -h | tail -n 1
if [ -z "$user_id" ]; then
user_id=20000
else
user_id=$(( $user_id+1 ))
if [ user_id -ge 30000 ]; then
echo $0": Provavelmente acabou os id's valido, procurando sequencialmente" > /home/openslx/log
#Da para tentar fazer algum código usando diff e {20000..29999}
#Ai nao precisa desse loop
for i in $(echo {20000..29999}); do
user_id=cat /etc/passwd | cut -d: -f3 | grep -e $i$
if [ -z "$user_id" ]; then
user_id=$i
break;
fi
done
if [ -z "$user_id" ]; then
echo $0": Acabou os id's validos" > /home/openslx/log
dialog \
--title 'Erro:' \
--msgbox 'As senhas não conferem. Tente novamente.' \
--msgbox 'Estorou o limite de ususario locais nessa maquina, impossivel criar mais' \
6 40
pass=$( dialog --stdout --passwordbox 'Por favor, digite a senha:' 0 0 )
check_pass=$( dialog --stdout --passwordbox 'Por favor, confirme a senha:' 0 0 )
done
user_id=$((10000+$(((RANDOM%10000)+1))))
check_user_id=`cat "$mount_path"/Openslx/config | grep "SLX_USB_PASSWD" | cut -f 3 -d ':' | grep -w "$user_id"`
#check if user_id already exists
#while [[ -n $check_user_id ]];
#do
exit 255
fi
fi
fi
#get the last id
#user_id=$((10000+$(((RANDOM%10000)+1))))
#check_user_id=`cat "$mount_path"/Openslx/config | grep "SLX_USB_PASSWD" | cut -f 3 -d ':' | grep -w "$user_id"`
#done
create_config
fim_setup
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment