diff --git a/talimatname/genel/p/postgresql/postgresql-check-db-dir b/talimatname/genel/p/postgresql/postgresql-check-db-dir new file mode 100644 index 000000000..8c904531f --- /dev/null +++ b/talimatname/genel/p/postgresql/postgresql-check-db-dir @@ -0,0 +1,49 @@ +#!/bin/sh + +# This script verifies that the postgresql data directory has been correctly +# initialized. We do not want to automatically initdb it, because that has +# a risk of catastrophic failure (ie, overwriting a valuable database) in +# corner cases, such as a remotely mounted database on a volume that's a +# bit slow to mount. But we can at least emit a message advising newbies +# what to do. + +PGDATA="$1" + +if [ -z "$PGDATA" ] +then + echo "Usage: $0 database-path" + exit 1 +fi + +# PGMAJORVERSION is major version +PGMAJORVERSION=10 +# PREVMAJORVERSION is the previous major version +PREVMAJORVERSION=9.6 + +# Check for the PGDATA structure +if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ] +then + # Check version of existing PGDATA + if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ] + then + : A-OK + elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ] + then + echo $"An old version of the database format was found." + echo $"type postgresql_db_yukselt.sh" + exit 1 + else + echo $"An old version of the database format was found." + echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION." + echo $"See http://www.postgresql.org/docs/$PGMAJORVERSION/static/upgrading.html" + exit 1 + fi +else + # No existing PGDATA! Warn the user to initdb it. + echo $"\"$PGDATA\" is missing or empty. Use a command like" + echo $" su - postgres -c \"initdb --locale en_US.UTF-8 -D '$PGDATA'\"" + echo $"with relevant options, to initialize the database cluster." + exit 1 +fi + +exit 0 diff --git a/talimatname/genel/p/postgresql/postgresql.kos-sil b/talimatname/genel/p/postgresql/postgresql.kos-sil index 7142b0037..960d583de 100644 --- a/talimatname/genel/p/postgresql/postgresql.kos-sil +++ b/talimatname/genel/p/postgresql/postgresql.kos-sil @@ -1,3 +1,4 @@ #!/bin/sh -pg_dumpall > /srv/pgsql/yedek/yedek-9.6.3 +su - postgres -c 'mkdir -p /srv/pgsql/yedek' +su - postgres -c 'pg_dumpall > /srv/pgsql/yedek/yedek-9.6.3' diff --git a/talimatname/genel/p/postgresql/postgresql.logrotate b/talimatname/genel/p/postgresql/postgresql.logrotate new file mode 100644 index 000000000..d68ccf71b --- /dev/null +++ b/talimatname/genel/p/postgresql/postgresql.logrotate @@ -0,0 +1,9 @@ +/var/log/postgresql { + daily + rotate 7 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/talimatname/genel/p/postgresql/postgresql.pam b/talimatname/genel/p/postgresql/postgresql.pam new file mode 100644 index 000000000..53724d1f8 --- /dev/null +++ b/talimatname/genel/p/postgresql/postgresql.pam @@ -0,0 +1,3 @@ +auth required pam_unix.so +account required pam_unix.so +session required pam_unix.so diff --git a/talimatname/genel/p/postgresql/postgresql_db_yukselt b/talimatname/genel/p/postgresql/postgresql_db_yukselt new file mode 100755 index 000000000..f5e278560 --- /dev/null +++ b/talimatname/genel/p/postgresql/postgresql_db_yukselt @@ -0,0 +1,44 @@ +#!/bin/sh + +PGDATA="$1" +PGBACKUP="$2" + +if [ -z "$PGDATA" ] +then + echo "Usage: $0 database-path backup-sql" + exit 1 +fi + +if [ -z "$PGBACKUP" ] +then + echo "Usage: $0 database-path backup-sql" + echo "Usage example:$0 /srv/pgsql/data /srv/pgsql/yedek/yedek-9.6.3" + exit 1 +fi + +if [ ! -f "$PGBACKUP" ] +then + echo "$PGBACKUP not found" + echo "Usage example:$0 /srv/pgsql/data /srv/pgsql/yedek/yedek-9.6.3" + exit 1 +fi + +# servis durdurulur. +servis postgresql stop + +# eski yedeğe alınır. +_ustdizin=$(dirname $PGDATA) +mv ${_ustdizin}/data ${_ustdizin}/eskidata + +# yeni dizin ve izinleri atanır. +mkdir ${_ustdizin}/data +chown postgres:postgres ${_ustdizin}/data + +# yeni vt oluşturulur. +su - postgres -c '/usr/bin/initdb -E UTF8 -D /srv/pgsql/data' + +servis postgresql start +sleep 3 + +su - postgres -c "psql -f $PGBACKUP" + diff --git a/talimatname/genel/p/postgresql/talimat b/talimatname/genel/p/postgresql/talimat index d935489de..01ff70ef0 100644 --- a/talimatname/genel/p/postgresql/talimat +++ b/talimatname/genel/p/postgresql/talimat @@ -1,26 +1,68 @@ # Tanım: Gelişmiş nesne-ilişkisel veritabanı yönetim sistemi (ORDBMS). # URL: http://www.postgresql.org/docs # Paketçi: milisarge -# Gerekler: +# Gerekler: python3 # Grup: sistem isim=postgresql -surum=9.6.3 +surum=10.5 devir=1 -kaynak=(https://ftp.postgresql.org/pub/source/v$surum/postgresql-$surum.tar.bz2) +kaynak=(https://ftp.postgresql.org/pub/source/v$surum/postgresql-$surum.tar.bz2 + postgresql.logrotate + postgresql.pam + postgresql-check-db-dir + postgresql_db_yukselt) derle() { cd $isim-$surum sed -i '/DEFAULT_PGSOCKET_DIR/s@/tmp@/run/postgresql@' src/include/pg_config_manual.h && - ./configure --prefix=/usr \ + ./configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --includedir=/usr/include \ + --datarootdir=/usr/share \ + --datadir=/usr/share/postgresql \ + --with-openssl \ + --with-tcl \ + --with-perl \ + --with-pam \ + --with-python \ + --with-libxml \ + --with-libxslt \ --enable-thread-safety \ - --with-openssl + --with-system-tzdata=/usr/share/zoneinfo \ + --enable-nls \ + --disable-rpath make make DESTDIR=$PKG install - cd doc/src/sgml - make DESTDIR=$PKG install-man - rm -rf $PKG/usr/share/doc + + PG_EXTENSIONS=${PG_EXTENSIONS:-"adminpack pgcrypto ltree xml2 postgres_fdw file_fdw hstore citext"} + + if [ "x$PG_EXTENSIONS" = "xALL" ];then + cd $SRC/$isim-$surum/contrib + make all + make install-strip DESTDIR=$PKG + else + for ext in $PG_EXTENSIONS; do + cd $SRC/$isim-$surum/contrib/$ext + make + make install-strip DESTDIR=$PKG + done + fi + + # logrotate betiği + mkdir -p $PKG/etc/logrotate.d + cat $SRC/$isim.logrotate > $PKG/etc/logrotate.d/$isim + + mkdir -p "${PKG}/etc/pam.d" + install -Dm 755 "${SRC}/postgresql-check-db-dir" -t "${PKG}/usr/bin" + install -Dm 755 "${SRC}/postgresql_db_yukselt" -t "${PKG}/usr/bin" + install -Dm 644 "${SRC}/postgresql.pam" "${PKG}/etc/pam.d/postgresql" + cd /sources/milis.git/ayarlar/servisler make DESTDIR=$PKG kur-$isim + + rm -rf $PKG/usr/share/doc + rm -rf $PKG/etc/sysconfig }