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

Add create config hd


Signed-off-by: default avatarThiago Abdo <tja14@inf.ufpr.br>
parent 480cc660
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,16 @@ function get_user { ...@@ -120,7 +120,16 @@ function get_user {
} }
function create_config { function success_message {
#show the confirmation message
dialog \
--title 'Cadastro:' \
--msgbox 'Cadastro realizado com sucesso.' \
6 40
}
function calculate_days_and_pass {
#get days since Linux Epoch (January 1, 1970) #get days since Linux Epoch (January 1, 1970)
seconds=`date +%s` seconds=`date +%s`
minutes=$(($seconds/60)) minutes=$(($seconds/60))
...@@ -129,6 +138,11 @@ function create_config { ...@@ -129,6 +138,11 @@ function create_config {
#encrypt password #encrypt password
encry_pass=`echo "$pass" | openssl passwd -1 -stdin` encry_pass=`echo "$pass" | openssl passwd -1 -stdin`
echo $encry_pass echo $encry_pass
}
function create_config {
#get days since Linux Epoch (January 1, 1970)
calculate_days_and_pass
#insert data in the log file #insert data in the log file
echo "$user_id $new_user active $date" >> "$mount_path"/Openslx/log echo "$user_id $new_user active $date" >> "$mount_path"/Openslx/log
...@@ -139,12 +153,23 @@ function create_config { ...@@ -139,12 +153,23 @@ function create_config {
echo "SLX_USB_SHADOW=$new_user:$encry_pass:$days:0:99999:7:::" >> "$mount_path"/Openslx/config echo "SLX_USB_SHADOW=$new_user:$encry_pass:$days:0:99999:7:::" >> "$mount_path"/Openslx/config
echo "SLX_USB_GROUP=$new_user:x:$user_id;" >> "$mount_path"/Openslx/config echo "SLX_USB_GROUP=$new_user:x:$user_id;" >> "$mount_path"/Openslx/config
success_message
}
function create_config_hd {
#show the confirmation message calculate_days_and_pass
dialog \
--title 'Cadastro:' \ #insert data in the log file
--msgbox 'Cadastro realizado com sucesso.' \ echo "$user_id $new_user active $date" >> "$mount_path"/openslx/log
6 40
#insert data in the config file
echo "SLX_PASSWD=$new_user:x:$user_id:$user_id::/home/$new_user:/bin/bash" >> "$mount_path"/openslx/config
echo "SLX_SHADOW=$new_user:$encry_pass:$days:0:99999:7:::" >> "$mount_path"/openslx/config
echo "SLX__GROUP=$new_user:x:$user_id;" >> "$mount_path"/openslx/config
success_message
} }
function show_menu { function show_menu {
...@@ -196,6 +221,7 @@ function usb_drive { ...@@ -196,6 +221,7 @@ function usb_drive {
function hd_drive { function hd_drive {
# crete the dir /home/openslx and config files # crete the dir /home/openslx and config files
if [ ! -d "/home/openslx" ]; then if [ ! -d "/home/openslx" ]; then
mkdir -p /home/openslx/ mkdir -p /home/openslx/
fi fi
...@@ -215,7 +241,7 @@ function hd_drive { ...@@ -215,7 +241,7 @@ function hd_drive {
else else
user_id=$(( $user_id+1 )) user_id=$(( $user_id+1 ))
if [ user_id -ge 30000 ]; then if [ user_id -ge 30000 ]; then
echo $0": Provavelmente acabou os id's valido, procurando sequencialmente" > /home/openslx/log 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} #Da para tentar fazer algum código usando diff e {20000..29999}
#Ai nao precisa desse loop #Ai nao precisa desse loop
for i in $(echo {20000..29999}); do for i in $(echo {20000..29999}); do
...@@ -226,7 +252,7 @@ function hd_drive { ...@@ -226,7 +252,7 @@ function hd_drive {
fi fi
done done
if [ -z "$user_id" ]; then if [ -z "$user_id" ]; then
echo $0": Acabou os id's validos" > /home/openslx/log echo $0": Acabou os id's validos" >> /home/openslx/log
dialog \ dialog \
--title 'Erro:' \ --title 'Erro:' \
--msgbox 'Estorou o limite de ususario locais nessa maquina, impossivel criar mais' \ --msgbox 'Estorou o limite de ususario locais nessa maquina, impossivel criar mais' \
...@@ -236,7 +262,8 @@ function hd_drive { ...@@ -236,7 +262,8 @@ function hd_drive {
fi fi
fi fi
create_config mount_path="/home"
create_config_hd
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment