Skip to content

Commit 044657d

Browse files
author
Kristan Kenney
committed
Merge branch 'staging/features' into main
2 parents 8c3d792 + 44c01fa commit 044657d

25 files changed

+388
-643
lines changed

bin/v-add-database-host

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ type=$1
1818
host=$2
1919
dbuser=$3
2020
password=$4; HIDE=4
21-
max_db=${6-500}
22-
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
23-
template=${8-template1}
21+
max_db=${5-500}
22+
charsets=${6}
23+
template=${7}
24+
port=${8}
2425

2526
# Includes
2627
source $HESTIA/func/main.sh
@@ -33,6 +34,8 @@ is_mysql_host_alive() {
3334
echo "host='$HOST'" >> $mycnf
3435
echo "user='$USER'" >> $mycnf
3536
echo "password='$PASSWORD'" >> $mycnf
37+
echo "port='$PORT'" >> $mycnf
38+
3639
chmod 600 $mycnf
3740
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' >/dev/null 2>&1
3841
rm $mycnf
@@ -45,7 +48,7 @@ is_mysql_host_alive() {
4548

4649
is_pgsql_host_alive() {
4750
export PGPASSWORD="$dbpass"
48-
psql -h $host -U $dbuser -c "SELECT VERSION()" > /dev/null 2>&1
51+
psql -h $host -U $dbuser -p $port -c "SELECT VERSION()" > /dev/null 2>&1
4952
if [ '0' -ne "$?" ]; then
5053
echo "Error: PostgreSQL connection to $host failed"
5154
log_event "$E_CONNECT" "$ARGUMENTS"
@@ -58,14 +61,21 @@ is_pgsql_host_alive() {
5861
# Verifications #
5962
#----------------------------------------------------------#
6063

61-
args_usage='TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]'
64+
args_usage='TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL] [PORT]'
6265
check_args '4' "$#" "$args_usage"
63-
is_format_valid 'host' 'dbuser' 'max_db' 'charsets' 'template'
66+
67+
if [ -z $charsets ]; then charsets="UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8"; fi
68+
if [ -z $template ]; then template="template1"; fi
69+
70+
database_set_default_ports
71+
72+
is_format_valid 'host' 'dbuser' 'max_db' 'charsets' 'template' 'port'
6473
#is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
6574
#is_type_valid "$DB_SYSTEM" "$type"
6675
is_dbhost_new
6776
is_password_valid
6877
dbpass="$password"
78+
6979
case $type in
7080
mysql) is_mysql_host_alive ;;
7181
pgsql) is_pgsql_host_alive ;;
@@ -85,11 +95,11 @@ date=$(echo "$time_n_date" |cut -f 2 -d \ )
8595
case $type in
8696
mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'";
8797
str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''";
88-
str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$time' DATE='$date'";;
98+
str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$time' DATE='$date' PORT='$port'";;
8999
pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'";
90100
str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'";
91101
str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'";
92-
str="$str TIME='$time' DATE='$date'";;
102+
str="$str TIME='$time' DATE='$date' PORT='$port'";;
93103
esac
94104

95105

bin/v-add-user-favourites

Lines changed: 0 additions & 125 deletions
This file was deleted.

bin/v-delete-user-favourites

Lines changed: 0 additions & 128 deletions
This file was deleted.

bin/v-list-database-host

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ format=${3-shell}
1616

1717
# Includes
1818
source $HESTIA/func/main.sh
19+
source $HESTIA/func/db.sh
1920

2021
# JSON list function
2122
json_list() {
2223
echo '{'
2324
echo ' "'$HOST'": {
2425
"HOST": "'$HOST'",
26+
"PORT": "'$PORT'",
2527
"TYPE": "'$type'",
2628
"CHARSETS": "'$CHARSETS'",
2729
"MAX_DB": "'$MAX_DB'",
@@ -38,6 +40,7 @@ json_list() {
3840
# SHELL list function
3941
shell_list() {
4042
echo "HOST: $HOST"
43+
echo "PORT: $PORT"
4144
echo "TYPE: $type"
4245
echo "CHARSETS: $CHARSETS"
4346
echo "MAX_DB: $MAX_DB"
@@ -51,15 +54,15 @@ shell_list() {
5154

5255
# PLAIN list function
5356
plain_list() {
54-
echo -ne "$HOST\t$type\t$CHARSETS\t$MAX_DB\t$U_SYS_USERS\t"
57+
echo -ne "$HOST\t$PORT\t$type\t$CHARSETS\t$MAX_DB\t$U_SYS_USERS\t"
5558
echo -e "$U_DB_BASES\t$TPL\t$SUSPENDED\t$TIME\t$DATE"
5659
}
5760

5861
# CSV list function
5962
csv_list() {
60-
echo -n "HOST,TYPE,CHARSETS,MAX_DB,U_SYS_USERS,"
63+
echo -n "HOST,PORT,TYPE,CHARSETS,MAX_DB,U_SYS_USERS,"
6164
echo "U_DB_BASES,TPL,SUSPENDED,TIME,DATE'"
62-
echo -n "$HOST,$type,\"$CHARSETS\",$MAX_DB,\"$U_SYS_USERS\","
65+
echo -n "$HOST,$PORT,$type,\"$CHARSETS\",$MAX_DB,\"$U_SYS_USERS\","
6366
echo "$U_DB_BASES,$TPL,$SUSPENDED,$TIME,$DATE"
6467
}
6568

@@ -81,6 +84,8 @@ is_format_valid 'host'
8184
is_type_format_valid "$type"
8285
is_object_valid "../../conf/$type" 'HOST' "$host"
8386

87+
# Set default port values if they don't exist in host configuration file
88+
database_set_default_ports
8489

8590
#----------------------------------------------------------#
8691
# Action #

0 commit comments

Comments
 (0)