logo

overlay

My (experimental) gentoo overlay

postgresql-check-db-dir (1013B)


      1 #!/bin/sh
      2 # Copyright 1999-2014 Gentoo Foundation
      3 # Distributed under the terms of the GNU General Public License v2
      4 
      5 eerror() {
      6     echo "$@" >&2
      7 }
      8 
      9 # Check that DATA_DIR has been set
     10 if [ -z ${DATA_DIR} ] ; then
     11     eerror "DATA_DIR not set"
     12     exit 1
     13 fi
     14 
     15 # Check that DATA_DIR exists
     16 if [ ! -d ${DATA_DIR} ] ; then
     17     eerror "Directory not found: ${DATA_DIR}"
     18     eerror "HINT: Ensure that DATA_DIR points to the right path."
     19     eerror "HINT: Or perhaps you need to create the database cluster:"
     20     eerror "    emerge --config dev-db/postgresql:@SLOT@"
     21     exit 1
     22 fi
     23 
     24 # Check for the existence of PostgreSQL's config files, and set the
     25 # proper mode and ownership.
     26 # Only three files should be checked as potentially other files
     27 # may be in PGDATA that should not be touched.
     28 for file in postgresql pg_hba pg_ident ; do
     29     file="${PGDATA%/}/${file}.conf"
     30     if [ ! -f ${file} ] ; then
     31         eerror "${file} not found"
     32         eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
     33         exit 1
     34     fi
     35 done