kamdbctl: new option DBINITASK to control the steps for db init
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 23 Oct 2019 06:47:19 +0000 (08:47 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 23 Oct 2019 06:47:19 +0000 (08:47 +0200)
- if set DBINITASK=yes, then each step requires confirmation (e.g.,
database creation, users creation, standard tables creation)
- can be useful when needing to run only some of the steps

utils/kamctl/kamctlrc
utils/kamctl/kamdbctl.mysql

index 5306a61..a49c79f 100644 (file)
@@ -52,6 +52,9 @@
 ## - known to work for: mysql
 # DBROOTPW="dbrootpw"
 
+## option to ask confirmation for all database creation steps
+# DBINITASK=yes
+
 ## database character set (used by MySQL when creating database)
 #CHARSET="latin1"
 
index e8f8d2e..bdb8b98 100644 (file)
@@ -238,24 +238,45 @@ kamailio_create () # pars: <database name>
                exit 1
        fi
 
-       kamailio_db_create $1
+       if [ "$DBINITASK" = "yes" ]; then
+               get_answer "ask" "Create the database '$1'? (y/n): "
+       else
+               ANSWER="y"
+       fi
+       if [ "$ANSWER" = "y" ]; then
+               kamailio_db_create $1
+       fi
 
-       kamailio_db_grant $1
+       if [ "$DBINITASK" = "yes" ]; then
+               get_answer "ask" "Create database users with access privileges? (y/n): "
+       else
+               ANSWER="y"
+       fi
+       if [ "$ANSWER" = "y" ]; then
+               kamailio_db_grant $1
+       fi
 
-       standard_create $1
+       if [ "$DBINITASK" = "yes" ]; then
+               get_answer "ask" "Create the standard database tables? (y/n): "
+       else
+               ANSWER="y"
+       fi
+       if [ "$ANSWER" = "y" ]; then
+               standard_create $1
+       fi
 
-       get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
+       get_answer $INSTALL_PRESENCE_TABLES "Create the presence related tables? (y/n): "
        if [ "$ANSWER" = "y" ]; then
                presence_create $1
        fi
 
-       get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
+       get_answer $INSTALL_EXTRA_TABLES "Create the tables for $EXTRA_MODULES? (y/n): "
        if [ "$ANSWER" = "y" ]; then
                HAS_EXTRA="yes"
                extra_create $1
        fi
 
-       get_answer $INSTALL_DBUID_TABLES "Install tables for $DBUID_MODULES? (y/n): "
+       get_answer $INSTALL_DBUID_TABLES "Create the tables for $DBUID_MODULES? (y/n): "
        if [ "$ANSWER" = "y" ]; then
                HAS_EXTRA="yes"
                dbuid_create $1