diff --git a/usb_drive/setup_usb.sh b/usb_drive/setup_usb.sh index 87c7913483e34a9027ba7af8e7a1c9d659696aff..ff5f63847982e9677549e2cbdf25b4ab9eb9a978 100755 --- a/usb_drive/setup_usb.sh +++ b/usb_drive/setup_usb.sh @@ -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) seconds=`date +%s` minutes=$(($seconds/60)) @@ -129,6 +138,11 @@ function create_config { #encrypt password encry_pass=`echo "$pass" | openssl passwd -1 -stdin` echo $encry_pass +} + +function create_config { + #get days since Linux Epoch (January 1, 1970) + calculate_days_and_pass #insert data in the log file echo "$user_id $new_user active $date" >> "$mount_path"/Openslx/log @@ -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_GROUP=$new_user:x:$user_id;" >> "$mount_path"/Openslx/config + success_message +} - #show the confirmation message - dialog \ - --title 'Cadastro:' \ - --msgbox 'Cadastro realizado com sucesso.' \ - 6 40 +function create_config_hd { + + calculate_days_and_pass + + #insert data in the log file + echo "$user_id $new_user active $date" >> "$mount_path"/openslx/log + + + #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 { @@ -196,6 +221,7 @@ function usb_drive { function hd_drive { # crete the dir /home/openslx and config files + if [ ! -d "/home/openslx" ]; then mkdir -p /home/openslx/ fi @@ -215,7 +241,7 @@ function hd_drive { 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 + 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 @@ -226,7 +252,7 @@ function hd_drive { fi done 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 \ --title 'Erro:' \ --msgbox 'Estorou o limite de ususario locais nessa maquina, impossivel criar mais' \ @@ -236,7 +262,8 @@ function hd_drive { fi fi - create_config + mount_path="/home" + create_config_hd }