Annotation of /trunk/installer/gtk-gui/usermanagement.sh
Parent Directory | Revision Log
Revision 772 -
(hide annotations)
(download)
(as text)
Wed Sep 24 10:44:47 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 4158 byte(s)
Wed Sep 24 10:44:47 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 4158 byte(s)
-moved images into data/ directory
1 | niro | 772 | # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/gtk-gui/usermanagement.sh,v 1.2 2008-09-24 10:44:21 niro Exp $ |
2 | niro | 719 | |
3 | export ROOT_PASSWORD_DIALOG=' | ||
4 | <window title="Root Password" icon-name="gtk-dialog-authentication" window_position="1" resizable="false"> | ||
5 | <vbox> | ||
6 | <pixmap> | ||
7 | niro | 772 | <input file>data/header.png</input> |
8 | niro | 719 | </pixmap> |
9 | <hbox spacing="160"> | ||
10 | <pixmap> | ||
11 | <input file stock="gtk-dialog-authentication"></input> | ||
12 | </pixmap> | ||
13 | <text> | ||
14 | <label>Enter root password</label> | ||
15 | </text> | ||
16 | </hbox> | ||
17 | <frame root> | ||
18 | <entry invisible_char="*" visibility="false"> | ||
19 | <input>echo "${ROOT_PASSWORD}"</input> | ||
20 | <variable>ROOT_PASSWORD</variable> | ||
21 | </entry> | ||
22 | <entry invisible_char="*" visibility="false"> | ||
23 | <input>echo "${ROOT_PASSWORD_RETYPE}"</input> | ||
24 | <variable>ROOT_PASSWORD_RETYPE</variable> | ||
25 | </entry> | ||
26 | </frame> | ||
27 | <hbox> | ||
28 | <button> | ||
29 | <label>back</label> | ||
30 | <input file stock="gtk-go-back"></input> | ||
31 | </button> | ||
32 | <button> | ||
33 | <label>next</label> | ||
34 | <input file stock="gtk-go-forward"></input> | ||
35 | </button> | ||
36 | </hbox> | ||
37 | </vbox> | ||
38 | </window> | ||
39 | ' | ||
40 | #<action signal="button-press-event">check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}"</action> | ||
41 | # <action type="closewindow">ROOT_PASSWORD</action> | ||
42 | |||
43 | export ADD_USER_DIALOG=' | ||
44 | <window title="User add" icon-name="gtk-dialog-authentication" window_position="1" resizable="false"> | ||
45 | <vbox> | ||
46 | <pixmap> | ||
47 | niro | 772 | <input file>data/header.png</input> |
48 | niro | 719 | </pixmap> |
49 | <hbox spacing="100"> | ||
50 | <pixmap> | ||
51 | <input file stock="gtk-dialog-authentication"></input> | ||
52 | </pixmap> | ||
53 | <text> | ||
54 | <label>Please enter the name of a user</label> | ||
55 | </text> | ||
56 | </hbox> | ||
57 | <frame username> | ||
58 | <entry> | ||
59 | <input>echo "${USER_NAME}"</input> | ||
60 | <variable>USER_NAME</variable> | ||
61 | </entry> | ||
62 | </frame> | ||
63 | <frame password> | ||
64 | <entry invisible_char="*" visibility="false"> | ||
65 | <input>echo "${USER_PASSWORD}"</input> | ||
66 | <variable>USER_PASSWORD</variable> | ||
67 | </entry> | ||
68 | <entry invisible_char="*" visibility="false"> | ||
69 | <input>echo "${USER_PASSWORD_RETYPE}"</input> | ||
70 | <variable>USER_PASSWORD_RETYPE</variable> | ||
71 | </entry> | ||
72 | </frame> | ||
73 | <hbox> | ||
74 | <button> | ||
75 | <label>back</label> | ||
76 | <input file stock="gtk-go-back"></input> | ||
77 | </button> | ||
78 | <button> | ||
79 | <label>next</label> | ||
80 | <input file stock="gtk-go-forward"></input> | ||
81 | </button> | ||
82 | </hbox> | ||
83 | </vbox> | ||
84 | </window> | ||
85 | ' | ||
86 | |||
87 | |||
88 | check_password() | ||
89 | { | ||
90 | local pass1="$1" | ||
91 | local pass2="$2" | ||
92 | |||
93 | echo "DEBUG: pass1='${pass1}'" | ||
94 | |||
95 | if [[ -z ${pass1} ]] | ||
96 | then | ||
97 | # echo "Empty Password given." | ||
98 | FAILURE_MESSAGE="Empty password given!" rundialog FAILURE_DIALOG | ||
99 | return 1 | ||
100 | fi | ||
101 | |||
102 | if [[ ${pass1} = ${pass2} ]] | ||
103 | then | ||
104 | # echo "Password match." | ||
105 | return 0 | ||
106 | else | ||
107 | FAILURE_MESSAGE="Password did not match!" rundialog FAILURE_DIALOG | ||
108 | # echo "DEBUG: pass1='${pass1}'" | ||
109 | # echo "DEBUG: pass2='${pass2}'" | ||
110 | # echo "Password did *not* match. | ||
111 | return 1 | ||
112 | fi | ||
113 | } | ||
114 | # needed to be available in the gtk-dialog | ||
115 | export -f check_password | ||
116 | |||
117 | |||
118 | ## main programm ## | ||
119 | rundialog_root_password_dialog() | ||
120 | { | ||
121 | rundialog ROOT_PASSWORD_DIALOG | ||
122 | echo "DEBUG: EXIT='${EXIT}'" | ||
123 | |||
124 | # save given variables in env | ||
125 | # they will be shown as default on error | ||
126 | export ROOT_PASSWORD | ||
127 | export ROOT_PASSWORD_RETYPE | ||
128 | |||
129 | case ${EXIT} in | ||
130 | abort) | ||
131 | echo "Aborted by user." | ||
132 | exit 1 | ||
133 | ;; | ||
134 | back) | ||
135 | # placeholder | ||
136 | return 1 | ||
137 | ;; | ||
138 | next) | ||
139 | if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}" | ||
140 | then | ||
141 | rundialog_root_password_dialog | ||
142 | fi | ||
143 | ;; | ||
144 | esac | ||
145 | } | ||
146 | |||
147 | rundialog_add_user_dialog() | ||
148 | { | ||
149 | rundialog ADD_USER_DIALOG | ||
150 | echo "DEBUG: EXIT='${EXIT}'" | ||
151 | |||
152 | # save given variables in env | ||
153 | # they will be shown as default on error | ||
154 | export USER_NAME | ||
155 | export USER_PASSWORD | ||
156 | export USER_PASSWORD_RETYPE | ||
157 | |||
158 | case ${EXIT} in | ||
159 | abort) | ||
160 | echo "Aborted by user." | ||
161 | exit 1 | ||
162 | ;; | ||
163 | back) | ||
164 | rundialog_root_password_dialog | ||
165 | rundialog_add_user_dialog | ||
166 | ;; | ||
167 | next) | ||
168 | if [[ -z ${USER_NAME} ]] | ||
169 | then | ||
170 | rundialog USERNAME_FAILURE | ||
171 | rundialog_add_user_dialog | ||
172 | fi | ||
173 | if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}" | ||
174 | then | ||
175 | rundialog_add_user_dialog | ||
176 | fi | ||
177 | ;; | ||
178 | esac | ||
179 | } | ||
180 | |||
181 | main_usermanagement() | ||
182 | { | ||
183 | rundialog_root_password_dialog | ||
184 | rundialog_add_user_dialog | ||
185 | |||
186 | # export all variables | ||
187 | export ROOT_PASSWORD | ||
188 | export USER_NAME | ||
189 | export USER_PASSWORD | ||
190 | } |