mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 05:44:08 -07:00
Merge pull request #180 from ikheetjeff/fix-db-mail
Fix db.sh + rebuild.sh mailadres & subject
This commit is contained in:
commit
138f41c145
2 changed files with 18 additions and 0 deletions
12
func/db.sh
12
func/db.sh
|
@ -29,6 +29,9 @@ mysql_connect() {
|
||||||
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' > $mysql_out 2>&1
|
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' > $mysql_out 2>&1
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: Connection to $HOST failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't connect to MySQL $HOST\n$(cat $mysql_out)" |\
|
echo -e "Can't connect to MySQL $HOST\n$(cat $mysql_out)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -59,6 +62,9 @@ mysql_dump() {
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: dump $database failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't dump database $database\n$(cat $err)" |\
|
echo -e "Can't dump database $database\n$(cat $err)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -82,6 +88,9 @@ psql_connect() {
|
||||||
psql -h $HOST -U $USER -c "SELECT VERSION()" > /dev/null 2>/tmp/e.psql
|
psql -h $HOST -U $USER -c "SELECT VERSION()" > /dev/null 2>/tmp/e.psql
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: Connection to $HOST failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't connect to PostgreSQL $HOST\n$(cat /tmp/e.psql)" |\
|
echo -e "Can't connect to PostgreSQL $HOST\n$(cat /tmp/e.psql)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -103,6 +112,9 @@ psql_dump() {
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: dump $database failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't dump database $database\n$(cat /tmp/e.psql)" |\
|
echo -e "Can't dump database $database\n$(cat /tmp/e.psql)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -610,6 +610,9 @@ rebuild_pgsql_database() {
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
||||||
echo "Error: postgresql config parsing failed"
|
echo "Error: postgresql config parsing failed"
|
||||||
if [ ! -z "$SENDMAIL" ]; then
|
if [ ! -z "$SENDMAIL" ]; then
|
||||||
|
subj="Error: postgresql config parsing failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo "Can't parse PostgreSQL config" | $SENDMAIL -s "$subj" $email
|
echo "Can't parse PostgreSQL config" | $SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
log_event "$E_PARSING" "$ARGUMENTS"
|
log_event "$E_PARSING" "$ARGUMENTS"
|
||||||
|
@ -621,6 +624,9 @@ rebuild_pgsql_database() {
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
echo "Error: Connection failed"
|
echo "Error: Connection failed"
|
||||||
if [ ! -z "$SENDMAIL" ]; then
|
if [ ! -z "$SENDMAIL" ]; then
|
||||||
|
subj="Error: Connection failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo "Database connection to PostgreSQL host $HOST failed" |\
|
echo "Database connection to PostgreSQL host $HOST failed" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue