mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
improved sql functions
This commit is contained in:
parent
cb99788a43
commit
1a1d333ea4
2 changed files with 186 additions and 354 deletions
|
@ -31,6 +31,32 @@ source $VESTA/conf/vesta.conf
|
|||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
is_mysql_host_alive() {
|
||||
mycnf=$(mktemp)
|
||||
echo "[client]">$mycnf
|
||||
echo "host='$HOST'" >> $mycnf
|
||||
echo "user='$USER'" >> $mycnf
|
||||
echo "password='$PASSWORD'" >> $mycnf
|
||||
chmod 600 $mycnf
|
||||
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' >/dev/null 2>&1
|
||||
rm $mycnf
|
||||
if [ '0' -ne "$?" ]; then
|
||||
echo "Error: MySQL connection to $host failed"
|
||||
log_event "$E_CONNECT" "$EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
}
|
||||
|
||||
is_pgsql_host_alive() {
|
||||
export PGPASSWORD="$dbpass"
|
||||
psql -h $host -U $dbuser -c "SELECT VERSION()" > /dev/null 2>&1
|
||||
if [ '0' -ne "$?" ]; then
|
||||
echo "Error: PostgreSQL connection to $host failed"
|
||||
log_event "$E_CONNECT" "$EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue