Skip to content

Commit 4fa3013

Browse files
committed
Refactoring stage III
1 parent b998c72 commit 4fa3013

File tree

3 files changed

+98
-205
lines changed

3 files changed

+98
-205
lines changed

bin/v_add_db_base

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
# Argument defenition
1919
user=$1
2020
database="$user"_"$2"
21-
db_user="$user"_"$3"
22-
db_password=$4
21+
dbuser="$user"_"$3"
22+
dbpass=$4
2323
type=$5
2424
host=$6
2525
encoding=${7-UTF8}
2626
encoding=$(echo "$encoding" |tr '[:lower:]' '[:upper:]')
2727

28-
# Importing variables
28+
# Includes
2929
source $VESTA/conf/vesta.conf
3030
source $VESTA/func/shared.sh
3131
source $VESTA/func/db.sh
@@ -35,18 +35,18 @@ source $VESTA/func/db.sh
3535
# Verifications #
3636
#----------------------------------------------------------#
3737

38-
check_args '5' "$#" 'user db db_user db_password type [host] [encoding]'
39-
validate_format 'user' 'database' 'db_user' 'db_password' 'encoding'
40-
is_system_enabled 'DB_SYSTEM'
38+
check_args '5' "$#" 'user db dbuser dbpass type [host] [encoding]'
39+
validate_format 'user' 'database' 'dbuser' 'dbpass' 'encoding'
40+
is_system_enabled "$DB_SYSTEM"
4141
is_type_valid "$DB_SYSTEM" "$type"
4242
is_object_valid 'user' 'USER' "$user"
4343
is_object_unsuspended 'user' 'USER' "$user"
4444
is_object_free 'db' 'DB' "$database"
4545
get_next_dbhost
46-
is_object_valid "$type" 'DBHOST' "$host"
46+
is_object_valid "../../../conf/$type" 'HOST' "$host"
47+
is_db_encoding_valid
4748
is_package_full 'DATABASES'
4849

49-
5050
#----------------------------------------------------------#
5151
# Action #
5252
#----------------------------------------------------------#
@@ -67,17 +67,18 @@ increase_dbhost_values
6767
increase_user_value "$user" '$U_DATABASES'
6868

6969
# Adding db to db conf
70-
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
71-
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPENDED='no' DATE='$DATE'"
70+
v_str="DB='$database' USER='$dbuser' HOST='$host' TYPE='$type'"
71+
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
72+
v_str="$v_str DATE='$DATE'"
7273
echo "$v_str" >> $USER_DATA/db.conf
7374
chmod 660 $USER_DATA/db.conf
7475

7576
# Hiding password
76-
EVENT="$DATE $SCRIPT $user $database $db_user ***** $type $host"
77-
EVENT="$EVENT $encoding"
77+
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
78+
EVENT="$EVENT ARGUMENTS='$user $database $dbuser ***** $type $host'"
7879

7980
# Logging
80-
log_history "$EVENT" "v_delete_db_base $user $database"
81+
log_history "$EVENT"
8182
log_event "$OK" "$EVENT"
8283

8384
exit

0 commit comments

Comments
 (0)