forked from outroll/vesta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-delete-database-host
executable file
·50 lines (37 loc) · 1.42 KB
/
v-delete-database-host
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# info: delete database server
# options: TYPE HOST
#
# The function for deleting the database host from vesta configuration. It will
# be deleted if there are no databases created on it only.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
type=$1
host=$2
# Includes
source $VESTA/func/main.sh
source $VESTA/func/db.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'TYPE HOST'
validate_format 'type' 'host'
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
is_type_valid "$DB_SYSTEM" "$type"
is_object_valid "../../conf/$type" 'HOST' "$host"
is_dbhost_free
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting server
sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "deleted $type database server $host" '' 'admin'
log_event "$OK" "$EVENT"
exit