From dbd0e859b7be3986fbad0574b842261ed545bc14 Mon Sep 17 00:00:00 2001 From: Richard Harding Date: Thu, 23 Jul 2009 20:56:00 -0400 Subject: [PATCH] * add the pgsql functions to the process controls --- process_functions.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/process_functions.sh b/process_functions.sh index e1ff9ee..3b276ea 100755 --- a/process_functions.sh +++ b/process_functions.sh @@ -12,6 +12,11 @@ MYSQL_STOP="sudo /etc/init.d/mysql stop > /dev/null" MYSQL_START="sudo /etc/init.d/mysql start > /dev/null" +# @todo need a much more universal way of doing this...sucks +PGSQL_STOP="sudo /etc/init.d/postgresql-8.3 stop > /dev/null" +PGSQL_START="sudo /etc/init.d/postgresql-8.3 start > /dev/null" + + function zprocess_running() { # $1 should be the process we want to look for o=$(ps cax | grep -c "$1\$") @@ -47,7 +52,55 @@ function zmysql_stop () { } # PgSQL +# @todo combine these into one function that we pass start/stop to +function zpgsql_stop () { + zprocess_running 'postgres' + started="$?" + + if [ $started -eq 1 ]; then + eval "$PGSQL_STOP" + else + echo "Postgres Not Running" + return 1 + fi + + # make sure that it's stopped + zprocess_running 'postgres' + started="$?" + if [ $started -eq 1 ]; then + echo "Could not stop Postgres" + return 0 + fi + + return 1 +} + +function zpgsql_start () { + zprocess_running 'postgres' + started="$?" + + if [ $started -eq 0 ]; then + eval "$PGSQL_START" + else + echo "Postgres Running" + return 1 + fi + + # make sure that it's running + zprocess_running 'postgres' + started="$?" + if [ $started -eq 0 ]; then + echo "Could not start Postgres" + return 0 + fi + + return 1 +} # ctags +function zctags () { + + +}