Skip to content

Commit 795f54c

Browse files
Kristan Kenneyunknown
authored andcommitted
Add v-rebuild-database
Allows the user to rebuild a single database.
1 parent 94ad4e8 commit 795f54c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

bin/v-rebuild-database

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# info: rebuild databases
3+
# options: USER
4+
#
5+
# The function for rebuilding a single database for a user
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
user=$1
14+
database=$2
15+
16+
# Includes
17+
source $HESTIA/func/main.sh
18+
source $HESTIA/func/db.sh
19+
source $HESTIA/func/rebuild.sh
20+
source $HESTIA/conf/hestia.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'USER DATABASE'
28+
is_format_valid 'user'
29+
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
30+
is_object_valid 'user' 'USER' "$user"
31+
is_object_valid 'db' 'DB' "$database"
32+
33+
34+
#----------------------------------------------------------#
35+
# Action #
36+
#----------------------------------------------------------#
37+
38+
# Get database values
39+
get_database_values
40+
41+
# Switching on db type
42+
case $TYPE in
43+
mysql) rebuild_mysql_database ;;
44+
pgsql) rebuild_pgsql_database ;;
45+
esac
46+
47+
U_DISK_DB=$((U_DISK_DB + U_DISK))
48+
U_DATABASES=$((U_DATABASES + 1))
49+
if [ "$SUSPENDED" = 'yes' ]; then
50+
SUSPENDED_DB=$((SUSPENDED_DB + 1))
51+
fi
52+
53+
update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB"
54+
update_user_value "$user" '$U_DATABASES' "$U_DATABASES"
55+
update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB"
56+
57+
58+
#----------------------------------------------------------#
59+
# Hestia #
60+
#----------------------------------------------------------#
61+
62+
# Logging
63+
log_event "$OK" "$ARGUMENTS"
64+
65+
exit

0 commit comments

Comments
 (0)