myvesta/bin/v-delete-database-host
2016-06-09 16:55:35 +03:00

51 lines
1.4 KiB
Bash
Executable File

#!/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 definition
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'
is_format_valid '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" "$ARGUMENTS"
exit