Skip to content

Commit 75d0ff4

Browse files
committed
Check in is_mysql_host_alive was broken and verfication failed. Entering “false” info would cause server to be added
1 parent 22cab5d commit 75d0ff4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bin/v-add-database-host

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ source $HESTIA/conf/hestia.conf
3434
is_mysql_host_alive() {
3535
mycnf=$(mktemp)
3636
echo "[client]">$mycnf
37-
echo "host='$HOST'" >> $mycnf
38-
echo "user='$USER'" >> $mycnf
39-
echo "password='$PASSWORD'" >> $mycnf
40-
echo "port='$PORT'" >> $mycnf
37+
echo "host='$host'" >> $mycnf
38+
echo "user='$user'" >> $mycnf
39+
echo "password='$password'" >> $mycnf
40+
echo "port='$port'" >> $mycnf
4141

4242
chmod 600 $mycnf
4343
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' >/dev/null 2>&1
44-
rm $mycnf
45-
if [ '0' -ne "$?" ]; then
44+
45+
if [ "$?" -ne '0' ]; then
4646
echo "Error: MySQL connection to $host failed"
4747
log_event "$E_CONNECT" "$ARGUMENTS"
4848
exit $E_CONNECT
@@ -52,7 +52,7 @@ is_mysql_host_alive() {
5252
is_pgsql_host_alive() {
5353
export PGPASSWORD="$dbpass"
5454
psql -h $host -U $dbuser -p $port -c "SELECT VERSION()" > /dev/null 2>&1
55-
if [ '0' -ne "$?" ]; then
55+
if [ "$?" -ne '0' ]; then
5656
echo "Error: PostgreSQL connection to $host failed"
5757
log_event "$E_CONNECT" "$ARGUMENTS"
5858
exit $E_CONNECT
@@ -74,7 +74,7 @@ database_set_default_ports
7474

7575
is_format_valid 'host' 'dbuser' 'max_db' 'charsets' 'template' 'port'
7676
#is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
77-
#is_type_valid "$DB_SYSTEM" "$type"
77+
is_type_valid "$DB_SYSTEM" "$type"
7878
is_dbhost_new
7979
is_password_valid
8080
dbpass="$password"

0 commit comments

Comments
 (0)