From c4027dd1d07f8afc573e3ecedd7d012ba1d5f148 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 31 Oct 2024 14:18:43 +0100 Subject: [PATCH] etc/profile.d/pg.sh --- etc/profile.d/pg.sh | 6 ++++++ lib/postgres/host_report.sql | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/etc/profile.d/pg.sh b/etc/profile.d/pg.sh index 86c0c85f..ab3c3e8d 100644 --- a/etc/profile.d/pg.sh +++ b/etc/profile.d/pg.sh @@ -1,4 +1,10 @@ which psql > /dev/null || return 0 + +pg_pgpass_sql() { + local quote="'" + awk -F: '/^[:alpha:\*]/{print "ALTER USER "$4" WITH PASSWORD '$quote'"$5"'$quote';"}' ~/.pgpass +} + pg_count() { declare dbs pwd tables length diff --git a/lib/postgres/host_report.sql b/lib/postgres/host_report.sql index c1dcd0a6..5ad12afe 100644 --- a/lib/postgres/host_report.sql +++ b/lib/postgres/host_report.sql @@ -10,8 +10,9 @@ CREATE VIEW host_report AS ,(SELECT MAX(hb.val) FROM host_info hb WHERE hb.key LIKE CONCAT('backup_servers.',hi.host,'.files_transfer')) as backup_files FROM host_info hi GROUP BY host - ORDER BY git_updated DESC,backup_updated DESC,host +ORDER BY git_updated DESC,backup_updated DESC,host ; GRANT ALL PRIVILEGES ON host_report TO nico; +GRANT ALL PRIVILEGES ON host_report TO icolas; GRANT ALL PRIVILEGES ON host_report TO www; GRANT ALL PRIVILEGES ON host_report TO root; -- 2.47.3