home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / scripts / destroydb < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.3 KB  |  80 lines

  1. #!/bin/sh
  2. # ----------------------------------------------------------------
  3. #   FILE
  4. #    createdb    create a postgres database
  5. #
  6. #   DESCRIPTION
  7. #    this program runs the monitor with the "-c" option to create
  8. #   the requested database.
  9. #
  10. #   IDENTIFICATION
  11. #     $Header: /private/postgres/src/scripts/RCS/destroydb,v 1.5 1992/08/19 00:37:25 mer Exp $
  12. # ----------------------------------------------------------------
  13.  
  14. #
  15. # find postgres tree
  16. #
  17.  
  18. if (test -z "$POSTGRESHOME")
  19. then
  20.     PG=/usr/postgres
  21. else
  22.     PG=$POSTGRESHOME
  23. fi
  24.  
  25. #
  26. # find monitor program
  27. #
  28.  
  29. if (test -f "$PG/bin/monitor")
  30. then
  31.     MONITOR=$PG/bin/monitor
  32. elif (test -f "MONITOR=$PG/obj*/support/monitor")
  33. then
  34.     MONITOR=$PG/obj*/support/monitor
  35. elif (test -n "$POSTGRESTREE")
  36. then
  37.     MONITOR=$POSTGRESTREE/obj*/support/monitor
  38. else
  39.     echo "$0: can't find the monitor program!"
  40.     exit 1
  41. fi
  42.  
  43. progname=$0
  44.  
  45. if (test -n "$PGPORT")
  46. then
  47.     port=$PGPORT
  48. else
  49.     port=4321
  50. fi
  51.  
  52. if (test -n "$PGHOST")
  53. then
  54.     host=$PGHOST
  55. else
  56.     host=localhost
  57. fi
  58.  
  59. dbname=$USER
  60.  
  61. while (test -n "$1")
  62. do
  63.     case $1 in 
  64.         -h) host=$2; shift;;
  65.         -p) port=$2; shift;;
  66.          *) dbname=$1;;
  67.     esac
  68.     shift;
  69. done
  70.  
  71. $MONITOR -TN -h $host -p $port -c "destroydb $dbname" template1
  72.  
  73. if (test $? -ne 0)
  74. then
  75.     echo "$progname: database destroy failed on $dbname."
  76.     exit 1
  77. fi
  78.  
  79. exit 0
  80.