#!/bin/sh # # chkconfig: 345 85 15 # description: postgresql database management system # processname: postmaster # pidfile: /var/run/postmaster.pid # PG_VERSION=8.1.5 RING=http://www.t.ring.gr.jp ARCHIVE=postgresql-$PG_VERSION #JDBC=$ARCHIVE-jdbc.patch PGINST=/usr/local/pgsql PGDATA=/var/local/pgsql/data81 # EUC-JP Unicode ENCODE=EUC-JP install() { #apt-get remove postgresql postgresql-devel postgresql-server postgresql-libs [ -f $ARCHIVE.tar.gz ] || wget $RING/archives/misc/db/postgresql-jp/$PG_VERSION/$ARCHIVE.tar.gz [ -f man.tar.gz ] || wget http://www.postgresql.jp/document/current/man.tar.gz #[ -f $JDBC ] || wget http://siisise.net/softlib/$JDBC [ -n $ANT_HOME ] || ANT_HOME=/usr/java/ant [ -f $ANT_HOME ] || ./ant.setup install rm -rf $ARCHIVE [ -d $ARCHIVE ] || tar zxvf $ARCHIVE.tar.gz #zcat $ARCHIVE-nls-psql-patch.gz | patch -p0 cd $ARCHIVE #patch -p1 <../$JDBC # tar zxvfC ../$JDBC src/interfaces ./configure \ --enable-nls=ja \ --with-perl \ --with-openssl \ --with-tcl \ --with-pam \ CFLAGS='-O2 -march=i686' # datadir /share # --datadir=$PGDATA \ # --with-pam --with-krb5=/usr/kerberos # rm -f $JAVA_HOME/jre/lib/ext/postgresql*.jar make clean make make install # cp $PGINST/share/java/postgresql.jar $JAVA_HOME/jre/lib/ext cd .. rm -rf $ARCHIVE groupadd -g 26 postgres useradd postgres -g postgres -u 26 cp postgresql.setup /etc/rc.d/init.d/postgresql chown postgres.postgres /etc/rc.d/init.d/postgresql echo "PATH=\$PATH:/usr/local/pgsql/bin" >/etc/profile.d/postgresql.sh echo "export PATH" >>/etc/profile.d/postgresql.sh echo "setenv PATH \$PATH:/usr/local/pgsql/bin" >/etc/profile.d/postgresql.csh chmod +x /etc/profile.d/postgresql.sh chmod +x /etc/profile.d/postgresql.csh chkconfig --add postgresql } remove(){ stop chkconfig --del postgresql rm -f /etc/rc.d/init.d/postgresql rm -f /etc/profile.d/postgresql.sh rm -f /etc/profile.d/postgresql.csh # rm -f $JAVA_HOME/jre/lib/ext/postgresql*.jar rm -rf /usr/local/pgsql userdel postgres } initdb() { [ -d $PGINST ] || install mkdir -p $PGDATA chown postgres.postgres $PGDATA chmod 700 $PGDATA su -l postgres -c "$PGINST/bin/initdb --no-locale -E $ENCODE -D $PGDATA" echo "-i"> $PGDATA/postmaster.opts.default chown postgres.postgres $PGDATA/postmaster.opts.default } removedb() { rm -rf $PGDATA } start() { [ -d $PGINST ] || install [ -d $PGDATA ] || initdb su - postgres -c "$PGINST/bin/pg_ctl -D $PGDATA -l logfile start" touch /var/lock/subsys/postgresql } stop() { #service postgresql stop su - postgres -c "$PGINST/bin/pg_ctl -D $PGDATA stop" rm -f /var/lock/subsys/postgresql } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; install) install ;; remove) remove ;; *) echo "postgresql {start|stop|restart|install|remove}" esac