Browse code

kamdbctl: typo in log message - core tables successfully installed

Piotr Gregor authored on 24/02/2021 07:20:14 • Daniel-Constantin Mierla committed on 24/02/2021 07:20:14
Showing 1 changed files
... ...
@@ -208,7 +208,7 @@ if [ -e $DB_SCHEMA/extensions-create.sql ]; then
208 208
 	fi
209 209
 fi
210 210
 
211
-minfo "Core Kamailio tables succesfully created."
211
+minfo "Core Kamailio tables successfully created."
212 212
 
213 213
 get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
214 214
 if [ "$ANSWER" = "y" ]; then
... ...
@@ -244,7 +244,7 @@ if [ $? -ne 0 ] || check_oracle_log ; then
244 244
 	exit 1
245 245
 fi
246 246
 
247
-minfo "Presence tables succesfully created."
247
+minfo "Presence tables successfully created."
248 248
 }
249 249
 
250 250
 extra_create() # pars: <database name>
... ...
@@ -266,7 +266,7 @@ for TABLE in $EXTRA_MODULES; do
266 266
 	fi
267 267
 done
268 268
 
269
-minfo "Extra tables succesfully created."
269
+minfo "Extra tables successfully created."
270 270
 }
271 271
 
272 272
 
Browse code

kamctl remove svn ID's and history

Olle E. Johansson authored on 03/06/2016 08:34:25
Showing 1 changed files
... ...
@@ -1,5 +1,4 @@
1 1
 #!/bin/sh
2
-# $Id$
3 2
 #
4 3
 # Script for adding and dropping Kamailio Oracle tables
5 4
 #
Browse code

kamctl: replaced openser with kamailio in variable and function names

Daniel-Constantin Mierla authored on 23/10/2012 14:49:29
Showing 1 changed files
... ...
@@ -38,10 +38,10 @@ if [ -z "$SQLPLUS" ] ; then
38 38
 	fi
39 39
 	export SQLPLUS
40 40
 fi
41
-if [ -z "$OPENSER_ORASEL" ] ; then
42
-	OPENSER_ORASEL=`which kamailio_orasel 2>/dev/null`
41
+if [ -z "$KAMAILIO_ORASEL" ] ; then
42
+	KAMAILIO_ORASEL=`which kamailio_orasel 2>/dev/null`
43 43
 	if [ -n "$SQLPLUS" ]; then
44
-		export OPENSER_ORASEL
44
+		export KAMAILIO_ORASEL
45 45
 	fi
46 46
 fi
47 47
 
... ...
@@ -78,10 +78,10 @@ oracle_root_cmd()
78 78
 }
79 79
 
80 80
 
81
-openser_drop()  # pars: <database name>
81
+kamailio_drop()  # pars: <database name>
82 82
 {
83 83
 if [ $# -ne 1 ] ; then
84
-	merr "openser_drop function takes one params"
84
+	merr "kamailio_drop function takes one params"
85 85
 	exit 1
86 86
 fi
87 87
 
... ...
@@ -119,13 +119,13 @@ if [ -n "$DBSYSUSER" ]; then
119 119
 fi
120 120
 
121 121
 minfo "Scheme '$DBROOTUSER' in database '$1' dropped"
122
-} #openser_drop
122
+} #kamailio_drop
123 123
 
124 124
 
125
-openser_create() # pars: <database name>
125
+kamailio_create() # pars: <database name>
126 126
 {
127 127
 if [ $# -ne 1 ] ; then
128
-	merr "openser_create function takes one param"
128
+	merr "kamailio_create function takes one param"
129 129
 	exit 1
130 130
 fi
131 131
 
... ...
@@ -220,7 +220,7 @@ get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
220 220
 if [ "$ANSWER" = "y" ]; then
221 221
 	extra_create $1
222 222
 fi
223
-} # openser_create
223
+} # kamailio_create
224 224
 
225 225
 
226 226
 presence_create() # pars: <database name>
... ...
@@ -281,8 +281,8 @@ oracle_dump()
281 281
 	if [ -n "$1" ]; then
282 282
 		SUFF="@$1"
283 283
 	fi
284
-	if [ -n "$OPENSER_ORASEL" ]; then
285
-		$OPENSER_ORASEL ${DBROUSER}/${DBROPW}$SUFF -BLNe \
284
+	if [ -n "$KAMAILIO_ORASEL" ]; then
285
+		$KAMAILIO_ORASEL ${DBROUSER}/${DBROPW}$SUFF -BLNe \
286 286
 		    "select * from table(dump_tables('$DBROOTUSER'));" >$2
287 287
 	else
288 288
 		echo "set feed 0 lin 8000 pages 0
Browse code

kamctl: moved from tools/ to utils/

- mv tools/kamctl utils/kamctl
- updated srdb1 Makefile and test/unit/include/common with the new
kamctl path

Andrei Pelinescu-Onciul authored on 09/10/2009 12:05:15
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,312 @@
1
+#!/bin/sh
2
+# $Id$
3
+#
4
+# Script for adding and dropping Kamailio Oracle tables
5
+#
6
+# History:
7
+
8
+##In you not have 'AS SYSDBA' access to database connect, comment next string
9
+##and Oracle administrator must create DBROOTUSER
10
+##(see scripts/oracle/admin/_create_as_sys.tmpl)
11
+DBSYSUSER="sys"
12
+
13
+
14
+# path to the database schemas
15
+DATA_DIR="/usr/local/share/kamailio"
16
+if [ -d "$DATA_DIR/oracle" ] ; then
17
+	DB_SCHEMA="$DATA_DIR/oracle"
18
+else
19
+	DB_SCHEMA="./oracle"
20
+fi
21
+
22
+
23
+##### ----------------------------------------------- #####
24
+### load ORACLE SQL base
25
+#
26
+if [ -f "$MYLIBDIR/kamdbfunc.oracle" ]; then
27
+	. "$MYLIBDIR/kamdbfunc.oracle"
28
+else
29
+	echo "Cannot load ORACLE core functions '$MYLIBDIR/kamdbfunc.oracle' - exiting ..."
30
+	exit -1
31
+fi
32
+
33
+if [ -z "$SQLPLUS" ] ; then
34
+	SQLPLUS=`which sqlplus 2>/dev/null`
35
+	if [ -z "$SQLPLUS" ]; then
36
+		merr "'sqlplus' tool not found: set SQLPLUS variable to correct tool path"
37
+		exit 1
38
+	fi
39
+	export SQLPLUS
40
+fi
41
+if [ -z "$OPENSER_ORASEL" ] ; then
42
+	OPENSER_ORASEL=`which kamailio_orasel 2>/dev/null`
43
+	if [ -n "$SQLPLUS" ]; then
44
+		export OPENSER_ORASEL
45
+	fi
46
+fi
47
+
48
+#################################################################
49
+ORALOG=/tmp/opensrdbctl.log
50
+
51
+if [ -z "$SED" ]; then
52
+	SED="sed"
53
+fi
54
+
55
+SED_ROOTUSER="$SED -e s/%DBROOTUSER%/$DBROOTUSER/g"
56
+SED_USERS="$SED_ROOTUSER;s/%DBROUSER%/$DBROUSER/g;s/%DBRWUSER%/$DBRWUSER/g"
57
+
58
+#################################################################
59
+# config vars
60
+#################################################################
61
+
62
+# 'db'-privileges (scheme) Oracle user
63
+if [ -z "$DBROOTUSER" ]; then
64
+	merr "scheme owner (pivileged user) 'DBROOTUSER' must be defined."
65
+	exit 1
66
+fi
67
+
68
+#################################################################
69
+oracle_root_cmd()
70
+{
71
+	prompt_oracle_pw root
72
+	SUFF=""
73
+	if [ -n "$1" ]; then
74
+		SUFF="@$1"
75
+	fi
76
+	ORACLE_ROOT_CMD="$SQLPLUS -S -L -R 3 $DBROOTUSER/${DBROOTPW}$SUFF"
77
+	export ORACLE_ROOT_CMD
78
+}
79
+
80
+
81
+openser_drop()  # pars: <database name>
82
+{
83
+if [ $# -ne 1 ] ; then
84
+	merr "openser_drop function takes one params"
85
+	exit 1
86
+fi
87
+
88
+oracle_root_cmd $1
89
+
90
+echo "DROP USER $DBROUSER CASCADE;
91
+      DROP USER $DBRWUSER CASCADE;" | $ORACLE_ROOT_CMD >$ORALOG
92
+if [ $? -ne 0 ] || check_oracle_log ; then
93
+	mwarn "Could not drop $DBRWUSER or $DBROUSER users, try to continue.."
94
+else
95
+	minfo "Database user deleted"
96
+fi
97
+
98
+$SED_ROOTUSER $DB_SCHEMA/inc/_dropsch.tmpl | $ORACLE_ROOT_CMD >$ORALOG
99
+if [ $? -ne 0 ] || check_oracle_log ; then
100
+	merr "Dropping scheme for '$DBROOTUSER' in database '$1' failed!"
101
+	exit 1
102
+fi
103
+
104
+if [ -n "$DBSYSUSER" ]; then
105
+	get_answer "ask" "Remove user '$DBROOTUSER' (complete remove scheme)? (y/n): "
106
+	if [ "$ANSWER" = "y" ]; then
107
+		prompt_oracle_pw sys
108
+		SUFF=""
109
+		if [ -n "$1" ]; then
110
+			SUFF="@$1"
111
+		fi
112
+		SYSCMD="$SQLPLUS -S -L -R 3 $DBSYSUSER/${DBSYSPW}$SUFF AS SYSDBA"
113
+		echo "DROP USER $DBROOTUSER CASCADE;" | $SYSCMD	>$ORALOG
114
+		if [ $? -ne 0 ] || check_oracle_log ; then
115
+			merr "Dropping scheme in database '$1' failed!"
116
+			exit 1
117
+		fi
118
+	fi
119
+fi
120
+
121
+minfo "Scheme '$DBROOTUSER' in database '$1' dropped"
122
+} #openser_drop
123
+
124
+
125
+openser_create() # pars: <database name>
126
+{
127
+if [ $# -ne 1 ] ; then
128
+	merr "openser_create function takes one param"
129
+	exit 1
130
+fi
131
+
132
+minfo "creating scheme for '$DBROOTUSER' in database '$1' ..."
133
+
134
+if [ -n "$DBSYSUSER" ]; then
135
+	get_answer "ask" "Create user '$DBROOTUSER' (is new scheme)? (y/n): "
136
+	if [ "$ANSWER" = "y" ]; then
137
+		prompt_oracle_pw sys
138
+		prompt_oracle_pw root
139
+		SUFF=""
140
+		if [ -n "$1" ]; then
141
+			SUFF="@$1"
142
+		fi
143
+		SYSCMD="$SQLPLUS -S -L -R 3 $DBSYSUSER/${DBSYSPW}$SUFF AS SYSDBA"
144
+
145
+		echo "create user $DBROOTUSER identified by $DBROOTPW
146
+		    default tablespace DATA temporary tablespace TEMP
147
+		    profile DEFAULT;" | $SYSCMD >$ORALOG
148
+		if [ $? -ne 0 ] || check_oracle_log ; then
149
+			mwarn "Create privileged user in database failed, perhaps they allready exist? Try to continue.."
150
+		fi
151
+
152
+		$SED_ROOTUSER $DB_SCHEMA/inc/_grantroot.tmpl | $SYSCMD >$ORALOG
153
+		if [ $? -ne 0 ] || check_oracle_log ; then
154
+			merr "Creating scheme in database '$1' failed!"
155
+			exit 1
156
+		fi
157
+	fi
158
+fi
159
+
160
+
161
+oracle_root_cmd $1
162
+
163
+$SED_ROOTUSER $DB_SCHEMA/inc/_createsch.tmpl | $ORACLE_ROOT_CMD >$ORALOG
164
+if [ $? -ne 0 ] || check_oracle_log ; then
165
+	merr "Creating scheme for '$DBROOTUSER' in database '$1' failed!"
166
+	exit 1
167
+fi
168
+
169
+cat $DB_SCHEMA/inc/_create_compat.sql | $ORACLE_ROOT_CMD >$ORALOG
170
+if [ $? -ne 0 ] || check_oracle_log ; then
171
+	merr "Creating compatibility functions for '$DBROOTUSER' in database '$1' failed!"
172
+	exit 1
173
+fi
174
+
175
+prompt_oracle_pw rw
176
+prompt_oracle_pw ro
177
+echo "create user $DBROUSER identified by $DBROPW
178
+    default tablespace DATA temporary tablespace TEMP profile DEFAULT;
179
+ grant connect to $DBROUSER;
180
+ create user $DBRWUSER identified by $DBRWPW
181
+    default tablespace DATA temporary tablespace TEMP profile DEFAULT;
182
+ grant connect to $DBRWUSER;" | $ORACLE_ROOT_CMD >$ORALOG
183
+if [ $? -ne 0 ] || check_oracle_log ; then
184
+	mwarn "Create user in database scheme failed, perhaps they allready exist? Try to continue.."
185
+fi
186
+
187
+$SED_USERS $DB_SCHEMA/inc/_grantfunc.tmpl | $ORACLE_ROOT_CMD >$ORALOG
188
+if [ $? -ne 0 ] || check_oracle_log ; then
189
+	merr "Make compatibility functions for users failed!"
190
+	exit 1
191
+fi
192
+
193
+
194
+for TABLE in $STANDARD_MODULES; do
195
+	mdbg "Creating core table: $TABLE"
196
+	cat $DB_SCHEMA/$TABLE-create.sql | $ORACLE_ROOT_CMD >$ORALOG
197
+	if [ $? -ne 0 ] || check_oracle_log ; then
198
+		merr "Creating core tables failed!"
199
+		exit 1
200
+	fi
201
+done
202
+
203
+if [ -e $DB_SCHEMA/extensions-create.sql ]; then
204
+	minfo "Creating custom extensions tables"
205
+	cat $DB_SCHEMA/extensions-create.sql | $ORACLE_ROOT_CMD >$ORALOG
206
+	if [ $? -ne 0 ] || check_oracle_log ; then
207
+		merr "Creating custom extensions tables failed!"
208
+		exit 1
209
+	fi
210
+fi
211
+
212
+minfo "Core Kamailio tables succesfully created."
213
+
214
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
215
+if [ "$ANSWER" = "y" ]; then
216
+	presence_create $1
217
+fi
218
+
219
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
220
+if [ "$ANSWER" = "y" ]; then
221
+	extra_create $1
222
+fi
223
+} # openser_create
224
+
225
+
226
+presence_create() # pars: <database name>
227
+{
228
+if [ $# -ne 1 ] ; then
229
+	merr "presence_create function takes one param"
230
+	exit 1
231
+fi
232
+
233
+minfo "creating presence tables..."
234
+oracle_root_cmd $1
235
+
236
+cat $DB_SCHEMA/presence-create.sql | $ORACLE_ROOT_CMD >$ORALOG
237
+if [ $? -ne 0 ] || check_oracle_log ; then
238
+	merr "Failed to create presence tables!"
239
+	exit 1
240
+fi
241
+
242
+cat $DB_SCHEMA/rls-create.sql | $ORACLE_ROOT_CMD >$ORALOG
243
+if [ $? -ne 0 ] || check_oracle_log ; then
244
+	merr "Failed to create rls-presence tables!"
245
+	exit 1
246
+fi
247
+
248
+minfo "Presence tables succesfully created."
249
+}
250
+
251
+extra_create() # pars: <database name>
252
+{
253
+if [ $# -ne 1 ] ; then
254
+	merr "extra_create function takes one param"
255
+	exit 1
256
+fi
257
+
258
+minfo "creating extra tables..."
259
+oracle_root_cmd $1
260
+
261
+for TABLE in $EXTRA_MODULES; do
262
+	mdbg "Creating extra table: $TABLE"
263
+	cat $DB_SCHEMA/$TABLE-create.sql | $ORACLE_ROOT_CMD >$ORALOG
264
+	if [ $? -ne 0 ] || check_oracle_log ; then
265
+		merr "Creating extra tables failed!"
266
+		exit 1
267
+	fi
268
+done
269
+
270
+minfo "Extra tables succesfully created."
271
+}
272
+
273
+
274
+oracle_dump()
275
+{
276
+	if [ $# -ne 2 ] ; then
277
+		merr "oracle_dump function takes two params"
278
+		exit 1
279
+	fi
280
+	prompt_oracle_pw rw
281
+	if [ -n "$1" ]; then
282
+		SUFF="@$1"
283
+	fi
284
+	if [ -n "$OPENSER_ORASEL" ]; then
285
+		$OPENSER_ORASEL ${DBROUSER}/${DBROPW}$SUFF -BLNe \
286
+		    "select * from table(dump_tables('$DBROOTUSER'));" >$2
287
+	else
288
+		echo "set feed 0 lin 8000 pages 0
289
+		    select * from table(dump_tables('$DBROOTUSER'));" | \
290
+			$SQLPLUS -S -L -R 3 ${DBROUSER}/${DBROPW}$SUFF >$2
291
+	fi
292
+	return $?
293
+}
294
+
295
+oracle_restore()
296
+{
297
+	if [ $# -ne 2 ] ; then
298
+		merr "oracle_restore function takes two params"
299
+		exit 1
300
+	fi
301
+	prompt_oracle_pw rw
302
+	SUFF=""
303
+	if [ -n "$1" ]; then
304
+		SUFF="@$1"
305
+	fi
306
+	cat "$2" | $SQLPLUS -S -L -R 3 ${DBRWUSER}/${DBRWPW}$SUFF >$ORALOG
307
+	if [ $? -ne 0 ] || check_oracle_log ; then
308
+		return 1
309
+	fi
310
+	return 0
311
+}
312
+