Magellan Linux

Annotation of /trunk/installer/ncurses-gui/usermanagement.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1033 - (hide annotations) (download) (as text)
Sun May 30 18:27:24 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 4462 byte(s)
-codeling style fixes, use local arrays
1 niro 1013 # $Id$
2    
3     root_password_dialog()
4     {
5     #ROOT_PASSWORD=$(passwordbox "root" "Enter a password for root:" 10 50)
6     #ROOT_PASSWORD_RETYPE=$(passwordbox "root" "Re-enter the password:" 10 50)
7 niro 1033 dialog \
8 niro 1013 --stdout \
9     --colors \
10     --title "root" \
11     --backtitle "${TITLE}" \
12     --insecure \
13     --mixedform "Enter a password for root:" 10 60 0 \
14     " Username:" 1 1 "root" 1 18 36 0 2 \
15     " Password:" 2 1 "${ROOT_PASSWORD}" 2 18 36 0 1 \
16 niro 1033 "Retype Password:" 3 1 "${ROOT_PASSWORD_RETYPE}" 3 18 36 0 1
17 niro 1013 }
18    
19     add_user_dialog()
20     {
21     #USER_NAME=$(inputbox "Create a user" "Please enter a username for daily use:" 10 50)
22     #if [[ ! -z ${USER_NAME} ]]
23     #then
24     # USER_PASSWORD=$(passwordbox "${USER_NAME}" "Enter a password for '${USER_NAME}':" 10 50)
25     # USER_PASSWORD_RETYPE=$(passwordbox "${USER_NAME}" "Enter a password for '${USER_NAME}':" 10 50)
26     #fi
27    
28 niro 1033 dialog \
29 niro 1013 --stdout \
30     --colors \
31     --title "User-Setup" \
32     --backtitle "${TITLE}" \
33     --insecure \
34     --mixedform "Please enter a username and password for daily use:" 10 60 0 \
35     " Username:" 1 1 "${USER_NAME}" 1 18 36 0 0 \
36     " Password:" 2 1 "${USER_PASSWORD}" 2 18 36 0 1 \
37 niro 1033 "Retype Password:" 3 1 "${USER_PASSWORD_RETYPE}" 3 18 36 0 1
38 niro 1013 }
39    
40     check_password()
41     {
42     local pass1="$1"
43     local pass2="$2"
44    
45     if [[ -z ${pass1} ]]
46     then
47     messagebox "Warning" "Empty password given!" 10 40
48     return 1
49     fi
50    
51     if [[ ${pass1} = ${pass2} ]]
52     then
53     return 0
54     else
55     messagebox "Warning" "Passwords did not match!" 10 40
56     return 1
57     fi
58     }
59    
60     rundialog_root_password_dialog()
61     {
62     # root_password_dialog
63     # case $? in
64     # -1) die "Error!" ;;
65     # 255) die "aborted by user" ;;
66     #
67     # 1)
68     # root_password_dialog
69     # ;;
70     #
71     # 0)
72     # export ROOT_PASSWORD
73     # if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}"
74     # then
75     # rundialog_root_password_dialog
76     # fi
77     # ;;
78     # esac
79    
80 niro 1033 local ROOT_USER_SETUP
81     ROOT_USER_SETUP=($(root_password_dialog))
82 niro 1013 case $? in
83     -1) die "Error!" ;;
84     255) die "aborted by user" ;;
85    
86     1)
87     root_password_dialog
88     ;;
89    
90     0)
91     #export ROOT_PASSWORD
92     #if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}"
93     #then
94     # rundialog_root_password_dialog
95     #fi
96    
97     # root username is array item 0!
98     ROOT_PASSWORD="${ROOT_USER_SETUP[1]}"
99     ROOT_PASSWORD_RETYPE="${ROOT_USER_SETUP[2]}"
100     # check array len
101     if [ ${#ROOT_USER_SETUP[*]} -ne 3 ]
102     then
103     messagebox "Warning" "You must re-type the password!" 10 40
104     rundialog_root_password_dialog
105     fi
106     if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}"
107     then
108     rundialog_root_password_dialog
109     fi
110     export ROOT_PASSWORD
111     ;;
112     esac
113    
114     debug "ROOT_PASSWORD='${ROOT_PASSWORD}'"
115     }
116    
117     rundialog_add_user_dialog()
118     {
119     # add_user_dialog
120     # case $? in
121     # -1) die "Error!" ;;
122     # 255) die "aborted by user" ;;
123     #
124     # 1)
125     # rundialog_root_password_dialog
126     # rundialog_add_user_dialog
127     # ;;
128     #
129     # 0)
130     # export USER_NAME
131     # export USER_PASSWORD
132     # if [[ -z ${USER_NAME} ]]
133     # then
134     # messagebox "Warning" "No username given!" 10 40
135     # rundialog_add_user_dialog
136     # fi
137     # if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}"
138     # then
139     # rundialog_add_user_dialog
140     # fi
141     # ;;
142     # esac
143    
144 niro 1033 local USER_SETUP
145     USER_SETUP=($(add_user_dialog))
146 niro 1013 case $? in
147     -1) die "Error!" ;;
148     255) die "aborted by user" ;;
149    
150     1)
151     rundialog_root_password_dialog
152     rundialog_add_user_dialog
153     ;;
154    
155     0)
156     # export USER_NAME
157     # export USER_PASSWORD
158     # if [[ -z ${USER_NAME} ]]
159     # then
160     # messagebox "Warning" "No username given!" 10 40
161     # rundialog_add_user_dialog
162     # fi
163     # if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}"
164     # then
165     # rundialog_add_user_dialog
166     # fi
167    
168     USER_NAME="${USER_SETUP[0]}"
169     USER_PASSWORD="${USER_SETUP[1]}"
170     USER_PASSWORD_RETYPE="${USER_SETUP[2]}"
171     # check array len
172     if [ ${#USER_SETUP[*]} -ne 3 ]
173     then
174     if [[ -z ${USER_SETUP[0]} ]]
175     then
176     messagebox "Warning" "No username given!" 10 40
177     else
178     messagebox "Warning" "You must re-type the password!" 10 40
179     fi
180     rundialog_add_user_dialog
181     fi
182     if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}"
183     then
184     rundialog_add_user_dialog
185     fi
186     export USER_NAME
187     export USER_PASSWORD
188     ;;
189     esac
190    
191     debug "USER_NAME='${USER_NAME}'"
192     debug "USER_PASSWORD='${USER_PASSWORD}'"
193     debug "USER_PASSWORD_RETYPE='${USER_PASSWORD_RETYPE}'"
194     }
195    
196     main_usermanagement()
197     {
198     rundialog_root_password_dialog
199     rundialog_add_user_dialog
200     }

Properties

Name Value
svn:keywords Id