Browse code

utils: Fix typos

Bastian Triller authored on 05/05/2022 16:28:28 • Henning Westerholt committed on 08/05/2022 15:30:14
Showing 1 changed files
... ...
@@ -20,7 +20,7 @@
20 20
 # 2006-10-19  Added address table (bogdan)
21 21
 # 2006-10-27  subscriber table cleanup; some columns are created only if
22 22
 #             serweb is installed (bogdan)
23
-# 2007-01-26  added seperate installation routine for presence related tables
23
+# 2007-01-26  added separate installation routine for presence related tables
24 24
 #             and fix permissions for the SERIAL sequences.
25 25
 # 2007-05-21  Move SQL database definitions out of this script (henning)
26 26
 # 2007-05-31  Move common definitions to kamdbctl.base file (henningw)
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
... ...
@@ -168,7 +168,7 @@ then
168 168
 	fi
169 169
 fi
170 170
 
171
-minfo "Core Kamailio tables succesfully created."
171
+minfo "Core Kamailio tables successfully created."
172 172
 
173 173
 get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
174 174
 if [ "$ANSWER" = "y" ]; then
... ...
@@ -216,7 +216,7 @@ for TABLE in $PRESENCE_TABLES; do
216 216
 	fi
217 217
 done
218 218
 
219
-minfo "Presence tables succesfully created."
219
+minfo "Presence tables successfully created."
220 220
 }  # end presence_create
221 221
 
222 222
 
... ...
@@ -251,7 +251,7 @@ for TABLE in $EXTRA_TABLES; do
251 251
 	fi
252 252
 done
253 253
 
254
-minfo "Extra tables succesfully created."
254
+minfo "Extra tables successfully created."
255 255
 }  # end extra_create
256 256
 
257 257
 
... ...
@@ -272,5 +272,5 @@ dbuid_create () # pars: <database name>
272 272
 			exit 1
273 273
 			fi
274 274
 		done
275
-	minfo "UID tables succesfully created."
275
+	minfo "UID tables successfully created."
276 276
 }  # end uid_create
Browse code

kamctl: do not set privileges on drouting tables without id for pgsql

- reported by #1256

Daniel-Constantin Mierla authored on 29/09/2017 16:21:53
Showing 1 changed files
... ...
@@ -241,9 +241,9 @@ done
241 241
 for TABLE in $EXTRA_TABLES; do
242 242
 	sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE $TABLE TO $DBRWUSER;"
243 243
 	sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
244
-	if [ $TABLE != "route_tree" ] ; then
244
+	if [ $TABLE != "route_tree" ] && [ $TABLE != "dr_gateways" ] && [ $TABLE != "dr_rules" ] ; then
245 245
 		sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE "$TABLE"_id_seq TO $DBRWUSER;"
246
-	    sql_query "$1" "GRANT SELECT ON TABLE "$TABLE"_id_seq TO $DBROUSER;"
246
+		sql_query "$1" "GRANT SELECT ON TABLE "$TABLE"_id_seq TO $DBROUSER;"
247 247
 	fi
248 248
 	if [ $? -ne 0 ] ; then
249 249
 		merr "Grant privileges to extra tables failed!"
Browse code

kamctl: kamdbctl - proper use of DBPORT for postgres

Daniel-Constantin Mierla authored on 30/06/2017 06:38:11
Showing 1 changed files
... ...
@@ -55,8 +55,8 @@ if [ -z "$DBPORT" ] ; then
55 55
 	CMD="psql -q -h $DBHOST -U $DBROOTUSER "
56 56
 	DUMP_CMD="pg_dump -h $DBHOST -U $DBROOTUSER -c"
57 57
 else
58
-	CMD="psql -q -h $DBHOST -p $DBHOST -U $DBROOTUSER "
59
-	DUMP_CMD="pg_dump -h $DBHOST -p $DBHOST -U $DBROOTUSER -c"
58
+	CMD="psql -q -h $DBHOST -p $DBPORT -U $DBROOTUSER "
59
+	DUMP_CMD="pg_dump -h $DBHOST -p $DBPORT -U $DBROOTUSER -c"
60 60
 fi
61 61
 
62 62
 #################################################################
Browse code

kamctl: added DBPORT option

- allows to specify database engine (mysql/psql) port
- requested by GH #916

Daniel-Constantin Mierla authored on 09/01/2017 19:35:47
Showing 1 changed files
... ...
@@ -51,8 +51,14 @@ if [ -z "$DBROOTUSER" ]; then
51 51
 	fi
52 52
 fi
53 53
 
54
-CMD="psql -q -h $DBHOST -U $DBROOTUSER "
55
-DUMP_CMD="pg_dump -h $DBHOST -U $DBROOTUSER -c"
54
+if [ -z "$DBPORT" ] ; then
55
+	CMD="psql -q -h $DBHOST -U $DBROOTUSER "
56
+	DUMP_CMD="pg_dump -h $DBHOST -U $DBROOTUSER -c"
57
+else
58
+	CMD="psql -q -h $DBHOST -p $DBHOST -U $DBROOTUSER "
59
+	DUMP_CMD="pg_dump -h $DBHOST -p $DBHOST -U $DBROOTUSER -c"
60
+fi
61
+
56 62
 #################################################################
57 63
 
58 64
 
Browse code

kamdbctl: more error help for missing .pgpass file

Daniel-Constantin Mierla authored on 13/06/2016 10:50:04
Showing 1 changed files
... ...
@@ -43,8 +43,10 @@ fi
43 43
 if [ -z "$DBROOTUSER" ]; then
44 44
 	DBROOTUSER="postgres"
45 45
 	if [ ! -r ~/.pgpass ]; then
46
-		merr "~/.pgpass does not exist, please create this file and support proper credentials for user postgres."
46
+		merr "~/.pgpass does not exist"
47
+		merr "create this file and add proper credentials for user postgres"
47 48
 		merr "Note: you need at least postgresql>= 7.3"
49
+		merr "Hint: .pgpass hostname must match DBHOST"
48 50
 		exit 1
49 51
 	fi
50 52
 fi
Browse code

kamdbct: fixed typo in pgpass name

Daniel-Constantin Mierla authored on 13/06/2016 10:33:28
Showing 1 changed files
... ...
@@ -43,7 +43,7 @@ fi
43 43
 if [ -z "$DBROOTUSER" ]; then
44 44
 	DBROOTUSER="postgres"
45 45
 	if [ ! -r ~/.pgpass ]; then
46
-		merr "~./pgpass does not exist, please create this file and support proper credentials for user postgres."
46
+		merr "~/.pgpass does not exist, please create this file and support proper credentials for user postgres."
47 47
 		merr "Note: you need at least postgresql>= 7.3"
48 48
 		exit 1
49 49
 	fi
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,4 +1,3 @@
1
-# $Id$
2 1
 #
3 2
 # Script for adding and dropping Kamailio Postgres tables
4 3
 #
Browse code

kamdbctl: added missing dbuid tables group creation

- patch by elactrum [at] jamailca.com

Daniel-Constantin Mierla authored on 10/09/2013 12:14:52
Showing 1 changed files
... ...
@@ -246,3 +246,24 @@ done
246 246
 
247 247
 minfo "Extra tables succesfully created."
248 248
 }  # end extra_create
249
+
250
+
251
+dbuid_create () # pars: <database name>
252
+{
253
+	if [ $# -ne 1 ] ; then
254
+		merr "dbuid_create function takes one param"
255
+		exit 1
256
+	fi
257
+
258
+	minfo "creating uid tables into $1 ..."
259
+
260
+	for TABLE in $DBUID_MODULES; do
261
+		mdbg "Creating uid table: $TABLE"
262
+		sql_query $1 < $DB_SCHEMA/$TABLE-create.sql
263
+		if [ $? -ne 0 ] ; then
264
+			merr "Creating uid tables failed at $TABLE!"
265
+			exit 1
266
+			fi
267
+		done
268
+	minfo "UID tables succesfully created."
269
+}  # end uid_create
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
... ...
@@ -72,10 +72,10 @@ sql_query()
72 72
 }
73 73
 
74 74
 
75
-openser_drop()  # pars: <database name>
75
+kamailio_drop()  # pars: <database name>
76 76
 {
77 77
 if [ $# -ne 1 ] ; then
78
-	merr "openser_drop function takes two params"
78
+	merr "kamailio_drop function takes two params"
79 79
 	exit 1
80 80
 fi
81 81
 
... ...
@@ -95,13 +95,13 @@ else
95 95
 fi
96 96
 
97 97
 minfo "Database $1 dropped"
98
-} #openser_drop
98
+} #kamailio_drop
99 99
 
100 100
 
101
-openser_create () # pars: <database name>
101
+kamailio_create () # pars: <database name>
102 102
 {
103 103
 if [ $# -ne 1 ] ; then
104
-	merr "openser_create function takes one param"
104
+	merr "kamailio_create function takes one param"
105 105
 	exit 1
106 106
 fi
107 107
 
... ...
@@ -172,7 +172,7 @@ get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
172 172
 if [ "$ANSWER" = "y" ]; then
173 173
 	extra_create $1
174 174
 fi
175
-} # openser_create
175
+} # kamailio_create
176 176
 
177 177
 
178 178
 presence_create () # pars: <database name>
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,248 @@
1
+# $Id$
2
+#
3
+# Script for adding and dropping Kamailio Postgres tables
4
+#
5
+# History:
6
+# 2006-05-16  added ability to specify MD5 from a configuration file
7
+#             FreeBSD does not have the md5sum function (norm)
8
+# 2006-07-14  Corrected syntax from MySQL to Postgres (norm)
9
+#             moved INDEX creation out of CREATE table statement into 
10
+#                  CREATE INDEX (usr_preferences, trusted)
11
+#             auto_increment isn't valid in Postgres, replaced with 
12
+#                  local AUTO_INCREMENT
13
+#             datetime isn't valid in Postgres, replaced with local DATETIME 
14
+#             split GRANTs for SERWeb tables so that it is only executed 
15
+#                  if SERWeb tables are created
16
+#             added GRANTs for re_grp table
17
+#             added CREATE pdt table (from PDT module)
18
+#             corrected comments to indicate Postgres as opposed to MySQL
19
+#             made last_modified/created stamps consistent to now() using 
20
+#                  local TIMESTAMP
21
+# 2006-10-19  Added address table (bogdan)
22
+# 2006-10-27  subscriber table cleanup; some columns are created only if
23
+#             serweb is installed (bogdan)
24
+# 2007-01-26  added seperate installation routine for presence related tables
25
+#             and fix permissions for the SERIAL sequences.
26
+# 2007-05-21  Move SQL database definitions out of this script (henning)
27
+# 2007-05-31  Move common definitions to kamdbctl.base file (henningw)
28
+#
29
+# 2007-06-11  Use a common control tool for database tasks, like the kamctl
30
+
31
+# path to the database schemas
32
+DATA_DIR="/usr/local/share/kamailio"
33
+if [ -d "$DATA_DIR/postgres" ] ; then
34
+	DB_SCHEMA="$DATA_DIR/postgres"
35
+else
36
+	DB_SCHEMA="./postgres"
37
+fi
38
+
39
+#################################################################
40
+# config vars
41
+#################################################################
42
+
43
+# full privileges Postgres user
44
+if [ -z "$DBROOTUSER" ]; then
45
+	DBROOTUSER="postgres"
46
+	if [ ! -r ~/.pgpass ]; then
47
+		merr "~./pgpass does not exist, please create this file and support proper credentials for user postgres."
48
+		merr "Note: you need at least postgresql>= 7.3"
49
+		exit 1
50
+	fi
51
+fi
52
+
53
+CMD="psql -q -h $DBHOST -U $DBROOTUSER "
54
+DUMP_CMD="pg_dump -h $DBHOST -U $DBROOTUSER -c"
55
+#################################################################
56
+
57
+
58
+# execute sql command with optional db name
59
+sql_query()
60
+{
61
+	if [ $# -gt 1 ] ; then
62
+		if [ -n "$1" ]; then
63
+			DB="$1"
64
+		else
65
+			DB=""
66
+		fi
67
+		shift
68
+		$CMD -d $DB -c "$@"
69
+	else
70
+		$CMD "$@"
71
+	fi
72
+}
73
+
74
+
75
+openser_drop()  # pars: <database name>
76
+{
77
+if [ $# -ne 1 ] ; then
78
+	merr "openser_drop function takes two params"
79
+	exit 1
80
+fi
81
+
82
+sql_query "template1" "drop database \"$1\";"
83
+if [ $? -ne 0 ] ; then
84
+	merr "Dropping database $1 failed!"
85
+	exit 1
86
+fi
87
+
88
+# postgresql users are not dropped automatically
89
+sql_query "template1" "drop user \"$DBRWUSER\"; drop user \"$DBROUSER\";"
90
+
91
+if [ $? -ne 0 ] ; then
92
+	mwarn "Could not drop $DBRWUSER or $DBROUSER users, try to continue.."
93
+else 
94
+	minfo "Database user deleted"
95
+fi
96
+
97
+minfo "Database $1 dropped"
98
+} #openser_drop
99
+
100
+
101
+openser_create () # pars: <database name>
102
+{
103
+if [ $# -ne 1 ] ; then
104
+	merr "openser_create function takes one param"
105
+	exit 1
106
+fi
107
+
108
+minfo "creating database $1 ..."
109
+
110
+sql_query "template1" "create database \"$1\";"
111
+if [ $? -ne 0 ] ; then
112
+	merr "Creating database failed!"
113
+	exit 1
114
+fi
115
+
116
+sql_query "$1" "CREATE FUNCTION "concat" (text,text) RETURNS text AS 'SELECT \$1 || \$2;' LANGUAGE 'sql';
117
+	        CREATE FUNCTION "rand" () RETURNS double precision AS 'SELECT random();' LANGUAGE 'sql';"
118
+# emulate mysql proprietary functions used by the lcr module in postgresql
119
+
120
+if [ $? -ne 0 ] ; then
121
+	merr "Creating mysql emulation functions failed!"
122
+	exit 1
123
+fi
124
+
125
+for TABLE in $STANDARD_MODULES; do
126
+    mdbg "Creating core table: $TABLE"
127
+    sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
128
+    if [ $? -ne 0 ] ; then
129
+	merr "Creating core tables failed!"
130
+	exit 1
131
+    fi
132
+done
133
+
134
+sql_query "$1" "CREATE USER $DBRWUSER WITH PASSWORD '$DBRWPW';
135
+		CREATE USER $DBROUSER WITH PASSWORD '$DBROPW';"
136
+if [ $? -ne 0 ] ; then
137
+	mwarn "Create user in database failed, perhaps they allready exist? Try to continue.."
138
+fi
139
+
140
+for TABLE in $STANDARD_TABLES; do
141
+	sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE $TABLE TO $DBRWUSER;"
142
+	sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
143
+	if [ $TABLE != "version" ] ; then
144
+		sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE "$TABLE"_id_seq TO $DBRWUSER;"
145
+    	sql_query "$1" "GRANT SELECT ON TABLE "$TABLE"_id_seq TO $DBROUSER;"
146
+	fi
147
+
148
+	if [ $? -ne 0 ] ; then
149
+		merr "Grant privileges to standard tables failed!"
150
+		exit 1
151
+	fi
152
+done
153
+
154
+if [ -e $DB_SCHEMA/extensions-create.sql ]
155
+then
156
+	minfo "Creating custom extensions tables"
157
+	sql_query $1 < $DB_SCHEMA/extensions-create.sql
158
+	if [ $? -ne 0 ] ; then
159
+	merr "Creating custom extensions tables failed!"
160
+	exit 1
161
+	fi
162
+fi
163
+
164
+minfo "Core Kamailio tables succesfully created."
165
+
166
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
167
+if [ "$ANSWER" = "y" ]; then
168
+	presence_create $1
169
+fi
170
+
171
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
172
+if [ "$ANSWER" = "y" ]; then
173
+	extra_create $1
174
+fi
175
+} # openser_create
176
+
177
+
178
+presence_create () # pars: <database name>
179
+{
180
+if [ $# -ne 1 ] ; then
181
+	merr "presence_create function takes one param"
182
+	exit 1
183
+fi
184
+
185
+minfo "creating presence tables into $1 ..."
186
+
187
+sql_query "$1" < $DB_SCHEMA/presence-create.sql
188
+
189
+if [ $? -ne 0 ] ; then
190
+	merr "Failed to create presence tables!"
191
+	exit 1
192
+fi
193
+
194
+sql_query "$1" < $DB_SCHEMA/rls-create.sql
195
+
196
+if [ $? -ne 0 ] ; then
197
+	merr "Failed to create rls-presence tables!"
198
+	exit 1
199
+fi
200
+
201
+for TABLE in $PRESENCE_TABLES; do
202
+	sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE $TABLE TO $DBRWUSER;"
203
+	sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
204
+	sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE "$TABLE"_id_seq TO $DBRWUSER;"
205
+    sql_query "$1" "GRANT SELECT ON TABLE "$TABLE"_id_seq TO $DBROUSER;"
206
+	if [ $? -ne 0 ] ; then
207
+		merr "Grant privileges to presence tables failed!"
208
+		exit 1
209
+	fi
210
+done
211
+
212
+minfo "Presence tables succesfully created."
213
+}  # end presence_create
214
+
215
+
216
+extra_create () # pars: <database name>
217
+{
218
+if [ $# -ne 1 ] ; then
219
+	merr "extra_create function takes one param"
220
+	exit 1
221
+fi
222
+
223
+minfo "creating extra tables into $1 ..."
224
+
225
+for TABLE in $EXTRA_MODULES; do
226
+    mdbg "Creating extra table: $TABLE"
227
+    sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
228
+    if [ $? -ne 0 ] ; then
229
+	merr "Creating extra tables failed!"
230
+	exit 1
231
+    fi
232
+done
233
+
234
+for TABLE in $EXTRA_TABLES; do
235
+	sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE $TABLE TO $DBRWUSER;"
236
+	sql_query "$1" "GRANT SELECT ON TABLE $TABLE TO $DBROUSER;"
237
+	if [ $TABLE != "route_tree" ] ; then
238
+		sql_query "$1" "GRANT ALL PRIVILEGES ON TABLE "$TABLE"_id_seq TO $DBRWUSER;"
239
+	    sql_query "$1" "GRANT SELECT ON TABLE "$TABLE"_id_seq TO $DBROUSER;"
240
+	fi
241
+	if [ $? -ne 0 ] ; then
242
+		merr "Grant privileges to extra tables failed!"
243
+		exit 1
244
+	fi
245
+done
246
+
247
+minfo "Extra tables succesfully created."
248
+}  # end extra_create