22cite about-plugin
33about-plugin ' postgres helper functions'
44
5- export PGVERSION=$( pg_config --version | awk ' {print $2}' )
6- export POSTGRES_BIN=$( pg_config --bindir)
5+ PGVERSION=$( pg_config --version | awk ' {print $2}' )
6+ POSTGRES_BIN=$( pg_config --bindir)
7+ export POSTGRES_BIN PGVERSION
78COMMON_PGDATA_PATHS=(" /usr/local/var/postgres" " /var/pgsql" " /Library/Server/PostgreSQL/Data" )
89for possible in " ${COMMON_PGDATA_PATHS[@]} " ; do
910 :
@@ -18,22 +19,22 @@ function postgres_start {
1819 group ' postgres'
1920
2021 echo ' Starting Postgres....'
21- $POSTGRES_BIN /pg_ctl -D $PGDATA -l $PGDATA /logfile start
22+ " $POSTGRES_BIN /pg_ctl" -D " $PGDATA " -l " $PGDATA /logfile" start
2223}
2324
2425function postgres_stop {
2526 about ' Stops PostgreSQL server'
2627 group ' postgres'
2728
2829 echo ' Stopping Postgres....'
29- $POSTGRES_BIN /pg_ctl -D $PGDATA -l $PGDATA /logfile stop -s -m fast
30+ " $POSTGRES_BIN /pg_ctl" -D " $PGDATA " -l " $PGDATA /logfile" stop -s -m fast
3031}
3132
3233function postgres_status {
3334 about ' Returns status of PostgreSQL server'
3435 group ' postgres'
3536
36- # $POSTGRES_BIN/pg_ctl -D $PGDATA status
37+ # " $POSTGRES_BIN/pg_ctl" -D " $PGDATA status"
3738 if [[ $( is_postgres_running) == " no server running" ]]; then
3839 echo " Postgres service [STOPPED]"
3940 else
@@ -42,29 +43,29 @@ function postgres_status {
4243}
4344
4445function is_postgres_running {
45- $POSTGRES_BIN /pg_ctl -D $PGDATA status | grep -F -o " no server running"
46+ " $POSTGRES_BIN /pg_ctl" -D " $PGDATA " status | grep -F -o " no server running"
4647}
4748
4849function postgres_restart {
4950 about ' Restarts status of PostgreSQL server'
5051 group ' postgres'
5152
5253 echo ' Restarting Postgres....'
53- $POSTGRES_BIN /pg_ctl -D $PGDATA restart
54+ " $POSTGRES_BIN /pg_ctl" -D " $PGDATA " restart
5455}
5556
5657function postgres_logfile {
5758 about ' View the last 500 lines from logfile'
5859 group ' postgres'
5960
60- tail -500 $PGDATA /logfile | less
61+ tail -500 " $PGDATA /logfile" | less
6162}
6263
6364function postgres_serverlog {
6465 about ' View the last 500 lines from server.log'
6566 group ' postgres'
6667
67- tail -500 $PGDATA /server.log | less
68+ tail -500 " $PGDATA /server.log" | less
6869}
6970
7071# function postgres_syslog {
0 commit comments