myvesta/bin/v_rebuild_databases
2012-04-30 12:32:11 +03:00

53 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
# info: rebuild databases
# options: user
#
# The function for rebuilding of all databases of a single user.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'user'
validate_format 'user'
is_system_enabled "$DB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Starting rebuild loop
for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do
get_database_values
# Switching on db type
case $TYPE in
mysql) rebuild_mysql_database ;;
pgsql) rebuild_pgsql_database ;;
esac
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$EVENT"
exit