Skip to content

Commit 81dbea9

Browse files
committed
Added documentation for DB function
1 parent 520f823 commit 81dbea9

17 files changed

+112
-41
lines changed

bin/v_add_db_base

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/bin/bash
2-
# info: adding data base
2+
# info: add database
3+
# arguments: user db db_user db_password type [host] [encoding]
4+
#
5+
# The function creates the database concatenating username and user_db.
6+
# Supported yypes of databases you can get using v_list_sys_config script.
7+
# If the host isn't stated and there are few hosts configured on the server,
8+
# then the host will be defined by one of three algorithms. "First" will choose
9+
# the first host in the list. "Random" will chose the host by a chance.
10+
# "Weight" will distribute new database through hosts evenly. Algorithm and
11+
# types of supported databases is designated in the main configuration file.
12+
313

414
#----------------------------------------------------------#
515
# Variable&Function #

bin/v_add_db_host

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
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
1119
port=$3
1220
db_user=$4
1321
db_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]'
3239
check_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'
3643
format_validation 'template'
3744

3845
# Checking db system is enabled
@@ -50,20 +57,19 @@ case $type in
5057
pgsql) is_pgsql_host_alive ;;
5158
esac
5259

60+
5361
#----------------------------------------------------------#
5462
# Action #
5563
#----------------------------------------------------------#
5664

5765
# Concatentating db host string
5866
case $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'";;
6874
esac
6975

bin/v_change_db_password

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
2-
# info: changing userdb password
2+
# info: change database user password
3+
# arguments: user db_name db_password
4+
#
5+
# The function for changing database user password to a database. It uses the
6+
# full name of database as argument.
7+
38

49
#----------------------------------------------------------#
510
# Variable&Function #

bin/v_delete_db_base

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
2-
# info: Deleting data base
2+
# info: delete database
3+
# arguments: user database
4+
#
5+
# The function for deleting the database. If database user have access to
6+
# another database, he will not be deleted.
7+
38

49
#----------------------------------------------------------#
510
# Variable&Function #

bin/v_delete_db_dbases

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
# info: deleteing all user databases
2+
# info: delete user databases
3+
# arguments: user
4+
#
5+
# The function deletes all user databases.
6+
37

48
#----------------------------------------------------------#
59
# Variable&Function #

bin/v_delete_db_host

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
2-
# info: adding data base server
2+
# info: delete database serve
3+
# arguments: type host
4+
#
5+
# The function for deleting the database host from vesta configuration. It will
6+
# be deleted if there are no databases created on it only.
7+
38

49
#----------------------------------------------------------#
510
# Variable&Function #

bin/v_list_db_base

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
# info: listing data base
2+
# info: list database
3+
# arguments: user database [format]
4+
#
5+
# The function for obtaining of all database's parameters.
6+
37

48
#----------------------------------------------------------#
59
# Variable&Function #

bin/v_list_db_bases

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22
# info: listing data bases
3+
# arguments: user [format]
4+
#
5+
# The function for obtaining the list of all user's databases.
6+
37

48
#----------------------------------------------------------#
59
# Variable&Function #

bin/v_list_db_host

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
# info: listing data base servers
2+
# info: list database host
3+
# arguments: type host [format]
4+
#
5+
# The function for obtaining host's database parameters.
6+
37

48
#----------------------------------------------------------#
59
# Variable&Function #
@@ -101,7 +105,7 @@ is_db_host_valid
101105
conf=$V_DB/$type.conf
102106

103107
# Defining fileds to select
104-
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
108+
fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
105109

106110
# Listing database
107111
case $format in

bin/v_list_db_hosts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
# info: listing data base servers
2+
# info: list data base servers
3+
# arguments: type [format]
4+
#
5+
# The function for obtaining the list of all hosts of the same databases' type.
6+
37

48
#----------------------------------------------------------#
59
# Variable&Function #
@@ -9,7 +13,6 @@
913
type=$1
1014
format=${2-shell}
1115

12-
1316
# Importing variables
1417
source $VESTA/conf/vars.conf
1518
source $V_FUNC/shared.func
@@ -37,13 +40,13 @@ is_type_valid 'db' "$type"
3740
conf=$V_DB/$type.conf
3841

3942
# Defining fileds to select
40-
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
43+
fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
4144

4245
# Listing database
4346
case $format in
4447
json) json_list ;;
4548
plain) nohead=1; shell_list;;
46-
shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
49+
shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $ACTIVE $DATE';
4750
shell_list | column -t ;;
4851
*) check_args '2' '0' 'type [format]'
4952
esac

0 commit comments

Comments
 (0)