Skip to content

Commit e2c1ef7

Browse files
authored
Merge pull request hestiacp#1463 from hestiacp/fix/2020-12-mysql_server_not_verified
[Bug] Mysql not verified + Other minor bugs
2 parents d9f9d56 + 6970c85 commit e2c1ef7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

bin/v-add-database-host

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ 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
4444
rm $mycnf
45-
if [ '0' -ne "$?" ]; then
45+
46+
if [ "$?" -ne '0' ]; then
4647
echo "Error: MySQL connection to $host failed"
4748
log_event "$E_CONNECT" "$ARGUMENTS"
4849
exit $E_CONNECT
@@ -52,7 +53,7 @@ is_mysql_host_alive() {
5253
is_pgsql_host_alive() {
5354
export PGPASSWORD="$dbpass"
5455
psql -h $host -U $dbuser -p $port -c "SELECT VERSION()" > /dev/null 2>&1
55-
if [ '0' -ne "$?" ]; then
56+
if [ "$?" -ne '0' ]; then
5657
echo "Error: PostgreSQL connection to $host failed"
5758
log_event "$E_CONNECT" "$ARGUMENTS"
5859
exit $E_CONNECT
@@ -73,8 +74,8 @@ if [ -z $template ]; then template="template1"; fi
7374
database_set_default_ports
7475

7576
is_format_valid 'host' 'dbuser' 'max_db' 'charsets' 'template' 'port'
76-
#is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
77-
#is_type_valid "$DB_SYSTEM" "$type"
77+
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
78+
is_type_valid "$DB_SYSTEM" "$type"
7879
is_dbhost_new
7980
is_password_valid
8081
dbpass="$password"

0 commit comments

Comments
 (0)