#! /bin/bash if ! grep -q postgres /etc/passwd; then useradd postgres echo postgres:postgres | chpasswd fi cd /ext/exp tar zxvf /ext/cmp/postgresql-*.*.*.tar.gz DIR=$(ls -d postgresql-*.*.*) cd $DIR ./configure --prefix=/ext/env/$DIR make all make install cd /ext/env ln -sf $DIR postgres chown -R postgres:postgres $DIR chown -h postgres:postgres postgres cd /ext/ini cat << EOF > postgres.sh export POSTGRES_HOME=/ext/env/postgres if ! echo \$PATH | grep -q postgres/bin; then PATH=\$POSTGRES_HOME/bin:\$PATH fi export PGDATA=\$POSTGRES_HOME/data EOF . /etc/profile cp /ext/cmp/postgresql*.jar $JAVA_HOME/jre/lib/ext chmod 644 $JAVA_HOME/jre/lib/ext/postgresql*.jar sudo -u postgres bash -c ". /etc/profile;initdb -D $PGDATA -E UTF-8 -W" cd $PGDATA if [ ! -e postgresql.conf.org ]; then cp -p postgresql.conf postgresql.conf.org sed -i '/silent_mode/{s/^#//;s/off/on/}' postgresql.conf fi if [ ! -e pg_hba.conf.org ]; then cp -p pg_hba.conf pg_hba.conf.org sed -i '/\(^local\|^host\)/s/trust$/md5/' pg_hba.conf fi