Use db_port,db_host, and db_username variables

This allows connecting to remote servers
This commit is contained in:
FusionPBX 2023-06-14 11:07:45 -06:00 committed by GitHub
parent d341ef3d93
commit d4e7851f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -4,6 +4,7 @@
export PGPASSWORD="zzz" export PGPASSWORD="zzz"
db_host=127.0.0.1 db_host=127.0.0.1
db_port=5432 db_port=5432
db_username=fusionpbx
switch_package=true # true or false switch_package=true # true or false
purge_voicemail=false purge_voicemail=false
@ -62,8 +63,8 @@ if [ .$purge_fax = .true ]; then
find /usr/local/freeswitch/storage/fax/* -name '*.pdf' -mtime +$days_keep_fax -exec rm {} \; find /usr/local/freeswitch/storage/fax/* -name '*.pdf' -mtime +$days_keep_fax -exec rm {} \;
fi fi
#delete from the database #delete from the database
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_fax_files WHERE fax_date < NOW() - INTERVAL '$days_keep_fax days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_fax_files WHERE fax_date < NOW() - INTERVAL '$days_keep_fax days'"
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_fax_logs WHERE fax_date < NOW() - INTERVAL '$days_keep_fax days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_fax_logs WHERE fax_date < NOW() - INTERVAL '$days_keep_fax days'"
else else
echo "not purging Faxes" echo "not purging Faxes"
fi fi
@ -78,7 +79,7 @@ if [ .$purge_call_recordings = .true ]; then
find /usr/local/freeswitch/recordings/*/archive/* -name '*.mp3' -mtime +$days_keep_call_recordings -exec rm {} \; find /usr/local/freeswitch/recordings/*/archive/* -name '*.mp3' -mtime +$days_keep_call_recordings -exec rm {} \;
fi fi
#Call recordings table uses a view. The data is from v_xml_cdr table. Changed in FusionPBX 5.0.7 and higher. The following line is useful to older versions. #Call recordings table uses a view. The data is from v_xml_cdr table. Changed in FusionPBX 5.0.7 and higher. The following line is useful to older versions.
#psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_call_recordings WHERE call_recording_date < NOW() - INTERVAL '90 days'" #psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_call_recordings WHERE call_recording_date < NOW() - INTERVAL '90 days'"
else else
echo "not purging Recordings." echo "not purging Recordings."
fi fi
@ -94,14 +95,14 @@ if [ .$purge_voicemail = .true ]; then
find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +$days_keep_voicemail -exec rm {} \; find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +$days_keep_voicemail -exec rm {} \;
find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +$days_keep_voicemail -exec rm {} \; find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +$days_keep_voicemail -exec rm {} \;
fi fi
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_voicemail_messages WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '$days_keep_voicemail days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_voicemail_messages WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '$days_keep_voicemail days'"
else else
echo "not purging voicemails." echo "not purging voicemails."
fi fi
if [ .$purge_cdrs = .true ]; then if [ .$purge_cdrs = .true ]; then
#delete call detail records older 90 days #delete call detail records older 90 days
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_xml_cdr WHERE start_stamp < NOW() - INTERVAL '$days_keep_cdrs days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_xml_cdr WHERE start_stamp < NOW() - INTERVAL '$days_keep_cdrs days'"
else else
echo "not purging CDRs." echo "not purging CDRs."
fi fi
@ -115,21 +116,21 @@ fi
#delete database_transactions older 90 days #delete database_transactions older 90 days
if [ .$purge_database_transactions = .true ]; then if [ .$purge_database_transactions = .true ]; then
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_database_transactions where transaction_date < NOW() - INTERVAL '$days_keep_database_transactions days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_database_transactions where transaction_date < NOW() - INTERVAL '$days_keep_database_transactions days'"
else else
echo "not purging database_transactions." echo "not purging database_transactions."
fi fi
#delete email_queue older 30 days #delete email_queue older 30 days
if [ .$purge_email_queue = .true ]; then if [ .$purge_email_queue = .true ]; then
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_email_queue where email_status = 'sent' and email_date < NOW() - INTERVAL '$days_keep_email_queue days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_email_queue where email_status = 'sent' and email_date < NOW() - INTERVAL '$days_keep_email_queue days'"
else else
echo "not purging email_queue." echo "not purging email_queue."
fi fi
#delete fax_queue older 30 days #delete fax_queue older 30 days
if [ .$purge_fax_queue = .true ]; then if [ .$purge_fax_queue = .true ]; then
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_fax_queue where fax_status = 'sent' and fax_date < NOW() - INTERVAL '$days_keep_fax_queue days'" psql --port $db_port --host=$db_host --username=$db_username -c "delete from v_fax_queue where fax_status = 'sent' and fax_date < NOW() - INTERVAL '$days_keep_fax_queue days'"
else else
echo "not purging fax_queue." echo "not purging fax_queue."
fi fi