Browse Source

kamdbctl: warn that drop cmd will drop existing DB, ask for confirmation (GH #1858)

- warn that the drop command will drop existing DB, ask for confirmation
- manually merge pull request GH #1858 from fredposner, fred at qxork dot com
Henning Westerholt 6 years ago
parent
commit
61eb1ac798
3 changed files with 20 additions and 12 deletions
  1. 1 1
      utils/kamctl/kamctlrc
  2. 8 0
      utils/kamctl/kamdbctl
  3. 11 11
      utils/kamctl/xhttp_pi/pi_framework.xml

+ 1 - 1
utils/kamctl/kamctlrc

@@ -15,7 +15,7 @@
 #
 # If you want to setup a database with kamdbctl, you must at least specify
 # this parameter.
-# DBENGINE=MYSQL
+DBENGINE=MYSQL
 
 ## database host
 # DBHOST=localhost

+ 8 - 0
utils/kamctl/kamdbctl

@@ -375,6 +375,14 @@ case $1 in
 	drop)
 		# delete kamailio database
 		# create new database structures
+
+		# confirm dropping of database
+		echo -e "This will drop your current database.\nIt is recommended to first backup your database.\n"
+		get_answer ask "Continue with drop? (y/n): "
+		if [ "$ANSWER" != "y" ]; then
+			exit 1
+		fi
+
 		shift
 		if [ $# -eq 1 ] ; then
 			DBNAME="$1"

+ 11 - 11
utils/kamctl/xhttp_pi/pi_framework.xml

@@ -219,6 +219,17 @@
 		<column><field>attrs</field><type>DB1_STR</type></column>
 		<column><field>description</field><type>DB1_STR</type></column>
 	</db_table>
+	<!-- Declaration of domainpolicy table-->
+	<db_table id="domainpolicy">
+		<table_name>domainpolicy</table_name>
+		<db_url_id>mysql</db_url_id>
+		<column><field>id</field><type>DB1_INT</type></column>
+		<column><field>rule</field><type>DB1_STR</type></column>
+		<column><field>type</field><type>DB1_STR</type></column>
+		<column><field>att</field><type>DB1_STR</type></column>
+		<column><field>val</field><type>DB1_STR</type></column>
+		<column><field>description</field><type>DB1_STR</type></column>
+	</db_table>
 	<!-- Declaration of domain table-->
 	<db_table id="domain">
 		<table_name>domain</table_name>
@@ -239,17 +250,6 @@
 		<column><field>value</field><type>DB1_STR</type></column>
 		<column><field>last_modified</field><type>DB1_DATETIME</type></column>
 	</db_table>
-	<!-- Declaration of domainpolicy table-->
-	<db_table id="domainpolicy">
-		<table_name>domainpolicy</table_name>
-		<db_url_id>mysql</db_url_id>
-		<column><field>id</field><type>DB1_INT</type></column>
-		<column><field>rule</field><type>DB1_STR</type></column>
-		<column><field>type</field><type>DB1_STR</type></column>
-		<column><field>att</field><type>DB1_STR</type></column>
-		<column><field>val</field><type>DB1_STR</type></column>
-		<column><field>description</field><type>DB1_STR</type></column>
-	</db_table>
 	<!-- Declaration of dr_gateways table-->
 	<db_table id="dr_gateways">
 		<table_name>dr_gateways</table_name>