11#! /bin/bash
2- # info: adding data base server
2+ # info: add new database server
3+ # arguments: type host port db_user db_password [max_db] [tpl]
4+ #
5+ # The function add new database server to the server pool. It supports local
6+ # and remote database servers, which is useful for clusters. By adding a host
7+ # you can set limit for number of databases on a host. Template parameter is
8+ # used only for PostgreSQL and has an default value "template1". You can read
9+ # more about templates in official PostgreSQL documentation.
10+
311
412# ----------------------------------------------------------#
513# Variable&Function #
@@ -11,9 +19,8 @@ host=$2
1119port=$3
1220db_user=$4
1321db_password=$5
14- max_usr=${6-300}
15- max_db=${7-300}
16- template=${8-template1}
22+ max_db=${6-300}
23+ template=${7-template1}
1724
1825
1926# Importing variables
@@ -28,11 +35,11 @@ source $V_FUNC/db.func
2835# ----------------------------------------------------------#
2936
3037# Checking arg number
31- args_usage=' type host port db_user db_password [max_usr] [ max_db] [tpl]'
38+ args_usage=' type host port db_user db_password [max_db] [tpl]'
3239check_args ' 5' " $# " " $args_usage "
3340
3441# Checking argument format
35- format_validation ' host' ' port' ' db_user' ' db_password' ' max_usr ' ' max_db'
42+ format_validation ' host' ' port' ' db_user' ' db_password' ' max_db'
3643format_validation ' template'
3744
3845# Checking db system is enabled
@@ -50,20 +57,19 @@ case $type in
5057 pgsql) is_pgsql_host_alive ;;
5158esac
5259
60+
5361# ----------------------------------------------------------#
5462# Action #
5563# ----------------------------------------------------------#
5664
5765# Concatentating db host string
5866case $type in
5967 mysql) new_str=" HOST='$host ' USER='$db_user ' PASSWORD='$db_password '" ;
60- new_str=" $new_str PORT='$port ' MAX_USERS='$max_usr '" ;
61- new_str=" $new_str MAX_DB='$max_db ' U_SYS_USERS=''" ;
68+ new_str=" $new_str PORT='$port ' MAX_DB='$max_db ' U_SYS_USERS=''" ;
6269 new_str=" $new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE '" ;;
6370 pgsql) new_str=" HOST='$host ' USER='$db_user ' PASSWORD='$db_password '" ;
6471 new_str=" $new_str PORT='$port ' TPL='$template '" ;
65- new_str=" $new_str MAX_USERS='$max_usr ' MAX_DB='$max_db '" ;
66- new_str=" $new_str U_SYS_USERS=''" ;
72+ new_str=" $new_str MAX_DB='$max_db ' U_SYS_USERS=''" ;
6773 new_str=" $new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE '" ;;
6874esac
6975
0 commit comments