Browse code

Added realm question and HA1 calculation

Nils Ohlmeier authored on 03/08/2003 22:55:12
Showing 1 changed files
... ...
@@ -38,6 +38,8 @@ TABLE_TYPE="TYPE=MyISAM"
38 38
 # user name column
39 39
 USERCOL="username"
40 40
 
41
+GENHA1='gen_ha1'
42
+
41 43
 #################################################################
42 44
 
43 45
 
... ...
@@ -135,9 +137,36 @@ drop database $1;
135 137
 EOF
136 138
 } #ser_drop
137 139
 
140
+# read realm
141
+prompt_realm() 
142
+{
143
+	printf "Doamin (realm) for the default user 'admin': "
144
+	read SIP_DOMAIN
145
+	echo
146
+}
147
+
148
+# calculate credentials for admin
149
+credentials()
150
+{
151
+	HA1=`$GENHA1 admin $SIP_DOMAIN heslo`
152
+	if [ $? -ne 0 ] ; then
153
+		echo "HA1 calculation failed"
154
+		exit 1
155
+	fi
156
+	HA1B=`$GENHA1 "admin@$SIP_DOMAIN" $SIP_DOMAIN heslo`
157
+	if [ $? -ne 0 ] ; then
158
+		echo "HA1B calculation failed"
159
+		exit 1
160
+	fi
161
+}
162
+
138 163
 ser_create () # pars: <database name> [<no_init_user>]
139 164
 {
140 165
 if [ $# -eq 1 ] ; then
166
+	if [ -z "$SIP_DOMAIN" ] ; then
167
+		prompt_realm
168
+	fi
169
+	credentials
141 170
 	# by default we create initial user
142 171
 	INITIAL_USER="INSERT INTO subscriber 
143 172
 		($USERCOL, password, first_name, last_name, phone, 
... ...
@@ -146,8 +175,7 @@ if [ $# -eq 1 ] ; then
146 175
 		VALUES ( 'admin', 'heslo', 'Initial', 'Admin', '123', 
147 176
 		'root@localhost', '2002-09-04 19:37:45', '0000-00-00 00:00:00', 
148 177
 		'57DaSIPuCm52UNe54LF545750cfdL48OMZfroM53', 'o', '', '', 
149
-		'0239482f19d262f3953186a725a6f53b', 'iptel.org', 
150
-		'a84e8abaa7e83d1b45c75ab15b90c320', 
178
+		'$HA1', '$SIP_DOMAIN', '$HA1B',
151 179
 		'65e397cda0aa8e3202ea22cbd350e4e9', 'admin' );"
152 180
 elif [ $# -eq 2 ] ; then
153 181
 	# if 3rd param set, don't create any initial user