You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							62 lines
						
					
					
						
							1.7 KiB
						
					
					
				
			
		
		
	
	
							62 lines
						
					
					
						
							1.7 KiB
						
					
					
				#!/bin/bash
 | 
						|
# info: update database disk usage
 | 
						|
# options: USER DATABASE
 | 
						|
#
 | 
						|
# example: v-update-database-disk admin wp_db
 | 
						|
#
 | 
						|
# This function recalculates disk usage for specific database.
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                Variables & Functions                     #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Argument definition
 | 
						|
user=$1
 | 
						|
database=$2
 | 
						|
 | 
						|
# Includes
 | 
						|
# shellcheck source=/etc/hestiacp/hestia.conf
 | 
						|
source /etc/hestiacp/hestia.conf
 | 
						|
# shellcheck source=/usr/local/hestia/func/main.sh
 | 
						|
source $HESTIA/func/main.sh
 | 
						|
# shellcheck source=/usr/local/hestia/func/db.sh
 | 
						|
source $HESTIA/func/db.sh
 | 
						|
# load config file
 | 
						|
source_conf "$HESTIA/conf/hestia.conf"
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                    Verifications                         #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
check_args '2' "$#" 'USER DATABASE'
 | 
						|
is_format_valid 'user' 'database'
 | 
						|
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
 | 
						|
is_object_valid 'user' 'USER' "$user"
 | 
						|
is_object_valid 'db' 'DB' "$database"
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Action                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Get database values
 | 
						|
get_database_values
 | 
						|
 | 
						|
# Switching on db type
 | 
						|
case $TYPE in
 | 
						|
	mysql) get_mysql_disk_usage ;;
 | 
						|
	pgsql) get_pgsql_disk_usage ;;
 | 
						|
esac
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Hestia                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Updating disk usage
 | 
						|
update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage"
 | 
						|
recalc_user_disk_usage
 | 
						|
 | 
						|
# Logging
 | 
						|
log_event "$OK" "$ARGUMENTS"
 | 
						|
 | 
						|
exit
 |