Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1035 - (show annotations) (download) (as text)
Sun May 30 18:37:54 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2721 byte(s)
-code cleanup
1 # $Id$
2
3 root_password_dialog()
4 {
5 dialog \
6 --stdout \
7 --colors \
8 --title "root" \
9 --backtitle "${TITLE}" \
10 --insecure \
11 --mixedform "Enter a password for root:" 10 60 0 \
12 " Username:" 1 1 "root" 1 18 36 0 2 \
13 " Password:" 2 1 "${ROOT_PASSWORD}" 2 18 36 0 1 \
14 "Retype Password:" 3 1 "${ROOT_PASSWORD_RETYPE}" 3 18 36 0 1
15 }
16
17 add_user_dialog()
18 {
19 dialog \
20 --stdout \
21 --colors \
22 --title "User-Setup" \
23 --backtitle "${TITLE}" \
24 --insecure \
25 --mixedform "Please enter a username and password for daily use:" 10 60 0 \
26 " Username:" 1 1 "${USER_NAME}" 1 18 36 0 0 \
27 " Password:" 2 1 "${USER_PASSWORD}" 2 18 36 0 1 \
28 "Retype Password:" 3 1 "${USER_PASSWORD_RETYPE}" 3 18 36 0 1
29 }
30
31 check_password()
32 {
33 local pass1="$1"
34 local pass2="$2"
35
36 if [[ -z ${pass1} ]]
37 then
38 messagebox "Warning" "Empty password given!" 10 40
39 return 1
40 fi
41
42 if [[ ${pass1} = ${pass2} ]]
43 then
44 return 0
45 else
46 messagebox "Warning" "Passwords did not match!" 10 40
47 return 1
48 fi
49 }
50
51 rundialog_root_password_dialog()
52 {
53 local ROOT_USER_SETUP
54 ROOT_USER_SETUP=($(root_password_dialog))
55 case $? in
56 -1) die "Error!" ;;
57 255) die "aborted by user" ;;
58
59 1)
60 root_password_dialog
61 ;;
62
63 0)
64 # root username is array item 0!
65 ROOT_PASSWORD="${ROOT_USER_SETUP[1]}"
66 ROOT_PASSWORD_RETYPE="${ROOT_USER_SETUP[2]}"
67 # check array len
68 if [ ${#ROOT_USER_SETUP[*]} -ne 3 ]
69 then
70 messagebox "Warning" "You must re-type the password!" 10 40
71 rundialog_root_password_dialog
72 fi
73 if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}"
74 then
75 rundialog_root_password_dialog
76 fi
77 export ROOT_PASSWORD
78 ;;
79 esac
80
81 debug "ROOT_PASSWORD='${ROOT_PASSWORD}'"
82 }
83
84 rundialog_add_user_dialog()
85 {
86 local USER_SETUP
87 USER_SETUP=($(add_user_dialog))
88 case $? in
89 -1) die "Error!" ;;
90 255) die "aborted by user" ;;
91
92 1)
93 rundialog_root_password_dialog
94 rundialog_add_user_dialog
95 ;;
96
97 0)
98 USER_NAME="${USER_SETUP[0]}"
99 USER_PASSWORD="${USER_SETUP[1]}"
100 USER_PASSWORD_RETYPE="${USER_SETUP[2]}"
101 # check array len
102 if [ ${#USER_SETUP[*]} -ne 3 ]
103 then
104 if [[ -z ${USER_SETUP[0]} ]]
105 then
106 messagebox "Warning" "No username given!" 10 40
107 else
108 messagebox "Warning" "You must re-type the password!" 10 40
109 fi
110 rundialog_add_user_dialog
111 fi
112 if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}"
113 then
114 rundialog_add_user_dialog
115 fi
116 export USER_NAME
117 export USER_PASSWORD
118 ;;
119 esac
120
121 debug "USER_NAME='${USER_NAME}'"
122 debug "USER_PASSWORD='${USER_PASSWORD}'"
123 debug "USER_PASSWORD_RETYPE='${USER_PASSWORD_RETYPE}'"
124 }
125
126 main_usermanagement()
127 {
128 rundialog_root_password_dialog
129 rundialog_add_user_dialog
130 }

Properties

Name Value
svn:keywords Id