Browse code

Allow openserdbctl to run unassisted by settings some variables that describe what additional tables to install

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2935 689a6050-402a-0410-94f2-e92a70836424

Dan Pascu authored on 18/10/2007 04:43:56
Showing 6 changed files
... ...
@@ -64,6 +64,20 @@
64 64
 # SED="sed"
65 65
 
66 66
 
67
+# Describe what additional tables to install. Valid values for the variables
68
+# below are yes/no/ask. With ask (default) it will interactively ask the user
69
+# for an answer, while yes/no allow for automated, unassisted installs.
70
+#
71
+
72
+# If to install tables for the modules in EXTRA_MODULES
73
+#INSTALL_EXTRA_TABLES=ask
74
+
75
+# If to install presence related tables
76
+#INSTALL_PRESENCE_TABLES=ask
77
+
78
+# If to install SERWEB related tables
79
+#INSTALL_SERWEB_TABLES=ask
80
+
67 81
 # define what modules should be installed
68 82
 
69 83
 # openser standard modules
... ...
@@ -32,6 +32,19 @@ if [ -z "$USERCOL" ]; then
32 32
 	USERCOL="username"
33 33
 fi
34 34
 
35
+# Describe what additional tables to install. Valid values for the variables
36
+# below are yes/no/ask. With ask it will interactively ask the user for the
37
+# answer, while yes/no allow for automated, unassisted installs.
38
+#
39
+
40
+# If to install tables for the modules in EXTRA_MODULES
41
+INSTALL_EXTRA_TABLES=${INSTALL_EXTRA_TABLES:-ask}
42
+
43
+INSTALL_PRESENCE_TABLES=${INSTALL_PRESENCE_TABLES:-ask}
44
+
45
+INSTALL_SERWEB_TABLES=${INSTALL_SERWEB_TABLES:-ask}
46
+
47
+
35 48
 # SQL definitions
36 49
 # If you change this definitions here, then you must change them
37 50
 # in db/schema/entities.xml too.
... ...
@@ -202,3 +215,29 @@ merr() {
202 202
 		echo "** ERROR: $1"
203 203
 	fi
204 204
 }
205
+
206
+# Get a y/n value from a variable. If the variable contains the keyword
207
+# `ask', then interactively ask the user for an answer.
208
+#
209
+# Arguments:
210
+#  $1 - variable holding yes/no/ask
211
+#  $2 - question to print if value of variable is ask
212
+#
213
+# Return:
214
+#  On return $ANSWER will be available with y/n
215
+#
216
+get_answer ()
217
+{
218
+    value=$1
219
+    question=$2
220
+    if [ "${value}" = "ask" ]; then
221
+        echo -n "$question"
222
+        read ANSWER
223
+    else
224
+        ANSWER=${value}
225
+    fi
226
+    ANSWER=${ANSWER:0:1}
227
+    ANSWER=${ANSWER/Y/y}
228
+    ANSWER=${ANSWER/N/n}
229
+}
230
+
... ...
@@ -263,25 +263,18 @@ openser_create() # pars: <database name>
263 263
 	    fi
264 264
 	done
265 265
 	
266
-	echo -n "Install presence related tables ?(y/n):"
267
-	read INPUT
268
-	if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
269
-	then
266
+	get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
267
+	if [ "$ANSWER" = "y" ]; then
270 268
 		presence_create $1
271 269
 	fi
272 270
 	
273
-	echo -n "Install extra tables - imc,cpl,siptrace,domainpolicy ?(y/n):"
274
-	read INPUT
275
-	if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
276
-	then
271
+	get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
272
+	if [ "$ANSWER" = "y" ]; then
277 273
 		extra_create $1
278 274
 	fi
279 275
 	
280
-	echo -n "Install SERWEB related tables ?(y/n):"
281
-	read INPUT
282
-	if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
283
-	then
284
-		HAS_SERWEB="yes"
276
+	get_answer $INSTALL_SERWEB_TABLES "Install SERWEB related tables? (y/n): "
277
+	if [ "$ANSWER" = "y" ]; then
285 278
 		serweb_create $1
286 279
 	fi
287 280
 	
... ...
@@ -71,20 +71,21 @@ for TABLE in $STANDARD_TABLES; do
71 71
     fi
72 72
 done
73 73
 
74
-echo -n "Install presence related tables ?(y/n):"
75
-read INPUT
76
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
77
-then
74
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
75
+if [ "$ANSWER" = "y" ]; then
78 76
 	presence_create $1
79 77
 fi
80 78
 
81
-echo -n "Install extra tables - imc,cpl,siptrace,domainpolicy ?(y/n):"
82
-read INPUT
83
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
84
-then
79
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
80
+if [ "$ANSWER" = "y" ]; then
85 81
 	extra_create $1
86 82
 fi
87 83
 
84
+#get_answer $INSTALL_SERWEB_TABLES "Install SERWEB related tables? (y/n): "
85
+#if [ "$ANSWER" = "y" ]; then
86
+#	serweb_create $1
87
+#fi
88
+
88 89
 } # openser_create
89 90
 
90 91
 
... ...
@@ -172,26 +172,18 @@ then
172 172
 	fi
173 173
 fi
174 174
 
175
-echo -n "Install presence related tables ?(y/n):"
176
-read INPUT
177
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
178
-then
175
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
176
+if [ "$ANSWER" = "y" ]; then
179 177
 	presence_create $1
180 178
 fi
181 179
 
182
-echo -n "Install extra tables - $EXTRA_MODULES ?(y/n):"
183
-read INPUT
184
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
185
-then
186
-	HAS_EXTRA="yes"
180
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
181
+if [ "$ANSWER" = "y" ]; then
187 182
 	extra_create $1
188 183
 fi
189 184
 
190
-echo -n "Install SERWEB related tables ?(y/n):"
191
-read INPUT
192
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
193
-then
194
-	HAS_SERWEB="yes"
185
+get_answer $INSTALL_SERWEB_TABLES "Install SERWEB related tables? (y/n): "
186
+if [ "$ANSWER" = "y" ]; then
195 187
 	serweb_create $1
196 188
 fi
197 189
 } # openser_create
... ...
@@ -179,24 +179,18 @@ fi
179 179
 
180 180
 minfo "Core OpenSER tables succesfully created."
181 181
 
182
-echo -n "Install presence related tables ?(y/n):"
183
-read INPUT
184
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
185
-then
182
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
183
+if [ "$ANSWER" = "y" ]; then
186 184
 	presence_create $1
187 185
 fi
188 186
 
189
-echo -n "Install extra tables - imc,cpl,siptrace,domainpolicy ?(y/n):"
190
-read INPUT
191
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
192
-then
187
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
188
+if [ "$ANSWER" = "y" ]; then
193 189
 	extra_create $1
194 190
 fi
195 191
 
196
-echo -n "Install SERWEB related tables ?(y/n):"
197
-read INPUT
198
-if [ "$INPUT" = "y" ] || [ "$INPUT" = "Y" ]
199
-then
192
+get_answer $INSTALL_SERWEB_TABLES "Install SERWEB related tables? (y/n): "
193
+if [ "$ANSWER" = "y" ]; then
200 194
 	serweb_create $1
201 195
 fi
202 196
 } # openser_create