- Fix errors for zsh commands

- Check for DIR presence before running a command
- add support for pgconfdigs folder
- Update README
This commit is contained in:
Yogesh Sharma 2024-01-10 12:14:53 -05:00
parent 4b57949ba8
commit a6c857bcb4
Signed by: yogesh.sharma
GPG key ID: 47778BF1D2A81254
2 changed files with 15 additions and 8 deletions

View file

@ -18,6 +18,12 @@
| PG_INST_NAME | <PG_DEV_NAME>-INST | Name of the install folder | | PG_INST_NAME | <PG_DEV_NAME>-INST | Name of the install folder |
| PG_ENV_CFLAGS | | Extra CFLAGS | | PG_ENV_CFLAGS | | Extra CFLAGS |
PostgreSQL extra configs shall be store in `${GIT_DIR}/pgconfigs/` in this naming convention:
```
pg${PGV}.conf
pg${PGV}-<Cluster #>.conf
```
### Advance setting for pg-env ### Advance setting for pg-env
| Config | Defaults | Description | | Config | Defaults | Description |

17
pg-env
View file

@ -112,21 +112,21 @@ compile_contrib() {
startdb(){ startdb(){
if [ -z "$1" ]; then if [ -z "$1" ]; then
pg_ctl start [ -d "${PGDATA}" ] && pg_ctl start
else else
for NodeN in "$@" for NodeN in "$@"
do do
pg_ctl start -D ${PGDATA}-${NodeN} [ -d "${PGDATA}-${NodeN}" ] && pg_ctl start -D ${PGDATA}-${NodeN}
done done
fi fi
} }
stopdb(){ stopdb(){
if [ -z "$1" ]; then if [ -z "$1" ]; then
pg_ctl stop [ -d "${PGDATA}" ] && pg_ctl stop
else else
for NodeN in "$@" for NodeN in "$@"
do do
pg_ctl stop -D ${PGDATA}-${NodeN} [ -d "${PGDATA}-${NodeN}" ] && pg_ctl stop -D ${PGDATA}-${NodeN}
done done
fi fi
} }
@ -138,12 +138,12 @@ restartdb(){
cleandb(){ cleandb(){
if [ -z "$1" ]; then if [ -z "$1" ]; then
setopt localoptions rmstarsilent [ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
rm -rf $PGDATA/* rm -rf $PGDATA/*
else else
for NodeN in "$@" for NodeN in "$@"
do do
setopt localoptions rmstarsilent [ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
rm -rf ${PGDATA}-${NodeN}/* rm -rf ${PGDATA}-${NodeN}/*
done done
fi fi
@ -151,11 +151,12 @@ cleandb(){
setupdb(){ setupdb(){
if [ -z "$1" ]; then if [ -z "$1" ]; then
initdb --data-checksums --username=sharyogi initdb --data-checksums --username=sharyogi
echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}.conf'" >> ${PGDATA}-${NodeN}/postgresql.conf
else else
for NodeN in "$@" for NodeN in "$@"
do do
initdb --data-checksums --username=sharyogi -D ${PGDATA}-${NodeN} initdb --data-checksums --username=sharyogi -D ${PGDATA}-${NodeN}
echo "include = '../../pg${PGV}-${NodeN}.conf'" >> ${PGDATA}-${NodeN}/postgresql.conf echo "include = '${GIT_DIR}/pgconfigs/pg${PGV}-${NodeN}.conf'" >> ${PGDATA}-${NodeN}/postgresql.conf
done done
fi fi
} }
@ -169,7 +170,7 @@ resetdb() {
resetall() { resetall() {
stopdb "$@" stopdb "$@"
setopt localoptions rmstarsilent [ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
rm -rf $PG_DEV_INST/* rm -rf $PG_DEV_INST/*
distclean distclean
compile compile