#!/bin/sh
#
# 簡易postgresqlインストールスクリプト
#
# (c) 2008.1.13 calico.jp
#
aptitude install libreadline6-dev zlib1g-dev
adduser postgres
mkdir /data
mkdir /data/pgsql
mkdir /usr/local/pgsql
mkdir /usr/local/src/pgsql
tar zxvf postgresql-8.4.14.tar.gz
chown -R postgres.postgres /data/pgsql
chown -R postgres.postgres /usr/local/pgsql
chown -R postgres.postgres /usr/local/src/pgsql
cd postgresql-8.4.14
su postgres -c './configure'
su postgres -c 'make'
su postgres -c 'make check'
su postgres -c 'make install'
echo "PATH="$PATH":/usr/local/pgsql/bin" >> /home/postgres/.bashrc
echo "export POSTGRES_HOME=/usr/local/pgsql" >> /home/postgres/.bashrc
echo "export PGLIB=/usr/local/pgsql/lib" >> /home/postgres/.bashrc
echo "export PGDATA=/data/pgsql" >> /home/postgres/.bashrc
echo "export MANPATH="$MANPATH":/usr/local/pgsql/man" >> /home/postgres/.bashrc
su postgres -c 'source /home/postgres/.bashrc'
su postgres -c '/usr/local/pgsql/bin/initdb -D /data/pgsql --encoding=EUC_JP --no-locale'
su postgres -c '/usr/local/pgsql/bin/pg_ctl -D /data/pgsql -w start'
su postgres -c '/usr/local/pgsql/bin/createdb --encoding=EUC_JP test'
su postgres -c '/usr/local/pgsql/bin/psql test'

