-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathuser
112 lines (83 loc) · 3.58 KB
/
user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
users () {
hostname="Arcris"
username=""
userpasswd=""
rootpasswd=""
dialog --backtitle "${title}" --title "${title_user_main}" --stdout --ok-label "${btn_ok_main}" --msgbox "${msg_user_main}" 7 37
##########################
# USER
##########################
while true; do
username=$(dialog --backtitle "${title}" --title "${titleuser}" \
--nocancel --inputbox "${msg_username}" 15 65 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
#El nombre de usuario debe comenzar con una letra minúscula.
#Puede contener minúsculas alfanuméricas y guiones.
if printf "%s" "${username}" | grep -Eoq "^[a-z][a-z0-9-]*$" \
&& [ "${#username}" -lt 20 ]; then
# El archivo de nombre de usuario reservado contiene nombres de usuario que deben evitarse
if grep -Fxq $username reserved_usernames ; then
dialog --backtitle "${title}" --title "${title_reserved_usernames}" --msgbox "${msg_reserved_usernames}" 10 40
else
inputs_match=false
while ! $inputs_match; do
input=$(dialog --backtitle "${title}" --title "${title_passwuser}" --clear \
--stdout --nocancel --insecure --passwordbox "${msg_passwduser} $username:\n " 10 55)
confirm_input=$(dialog --backtitle "${title}" --title "${title_passwuserconfirm} $username |-" \
--clear --stdout --insecure --no-cancel --passwordbox "${msg_passwuserconfirm}" 10 55)
if [ -z "$input" ]; then
dialog --backtitle "${title}" --title "${title_passwusernull}" --msgbox "${msg_passwusernull}" 7 60
elif [ "$input" != "$confirm_input" ]; then
dialog --backtitle "${title}" --title "${title_error}" --msgbox "${msg_passwuserfail}" 7 60
else
userpasswd="$input"
inputs_match=true
fi
done
break
fi
else
dialog --backtitle "${title}" --title "${title_userfail}" --msgbox "${msg_userfail}" 11 80
fi
fi
done
##########################
# HOSTNAME
##########################
#while true; do
# hostname=$(dialog --backtitle "${title}" --title "${title_hostname}" --nocancel \
# --inputbox "${msg_hostname}" 12 65 "ArcriS" 3>&1 1>&2 2>&3)
#
#
# # Hostname must be alpha-numeric and may contain a dash only in between
# if printf "%s" "$hostname" | grep -Eoq "^[a-zA-Z0-9-]{1,63}$" \
# && [ "${hostname:0:1}" != "-" ] \
# && [ "${hostname: -1}" != "-" ]; then
# break
# else
# dialog --backtitle "${title}" --title "${title_hostname_fail}" --msgbox "${msg_hostname_fail}" 12 68
# fi
#
# done
dialog --backtitle "${title}" --title "-| Root |-" --stdout --ok-label "${btn_ok_main}" --msgbox "${msg_passwdroot_main}" 7 43
##########################
# PASSWD ROOT
##########################
inputs_match=false
while ! $inputs_match; do
input=$(dialog --backtitle "${title}" --title "${title_passroot}" --clear --stdout --nocancel \
--insecure --passwordbox "${msg_passroot}" 13 50)
confirm_input=$(dialog --backtitle "${title}" --title "${title_passroot_confirm}" --clear --stdout --no-cancel \
--insecure --passwordbox "${msg_passroot_confirm}" 10 60)
if [ -z "$input" ]; then
dialog --backtitle "${title}" --title "${title_passrootnull}" --msgbox "${msg_passrootnull}" 7 55
elif [ "$input" != "$confirm_input" ]; then
dialog --title "${title_passroot_error}" --msgbox "${msg_passroot_error}" 7 58
else
rootpasswd="$input"
inputs_match=true
fi
done
sectionuser=1
}