34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -uo pipefail
|
|
#==============================================================#
|
|
# File : pg-cluster
|
|
# Desc : return pgsql cluster name
|
|
# Ctime : 2020-12-17
|
|
# Mtime : 2020-12-17
|
|
# Path : /pg/bin/pg-cluster
|
|
# Deps : psql
|
|
# License : Apache-2.0 @ https://pigsty.io/docs/about/license/
|
|
# Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com)
|
|
#==============================================================#
|
|
PROG_NAME="$(basename $0)"
|
|
PROG_DIR="$(cd $(dirname $0) && pwd)"
|
|
|
|
|
|
#--------------------------------------------------------------#
|
|
# Usage #
|
|
#--------------------------------------------------------------#
|
|
# get pg_cluster from local conn or meta file
|
|
function pg_cluster() {
|
|
local cluster_name=$(psql -AXtwqc "SHOW cluster_name;")
|
|
if [[ ! -z "${cluster_name}" ]]; then
|
|
echo "${cluster_name}"
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
|
|
#--------------------------------------------------------------#
|
|
# Main #
|
|
#--------------------------------------------------------------#
|
|
pg_cluster |