diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-07-01 11:01:03 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-07-01 11:01:03 +0200 |
commit | 8c49d3b08882c0c5a6bd546fd5bf0a14e68b3357 (patch) | |
tree | 845c5837566dafec8d5945f09115bc278175e856 | |
parent | 00683dad1a27a49e99f4a28e3924e1c97b1b9594 (diff) | |
download | postgresql-setup-8c49d3b08882c0c5a6bd546fd5bf0a14e68b3357.tar.gz postgresql-setup-8c49d3b08882c0c5a6bd546fd5bf0a14e68b3357.tar.xz postgresql-setup-8c49d3b08882c0c5a6bd546fd5bf0a14e68b3357.zip |
Generate postgresql.service and configuration file
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.am | 14 | ||||
-rw-r--r-- | conf/postgresql.in | 7 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | postgresql-setup.in | 2 | ||||
-rw-r--r-- | postgresql.service | 63 | ||||
-rw-r--r-- | postgresql.service.in | 42 |
7 files changed, 74 insertions, 67 deletions
@@ -13,3 +13,5 @@ postgresql*-setup postgresql*-ctl postgresql*-setup.1 *.tar.gz +conf/postgresql* +postgresql*.service diff --git a/Makefile.am b/Makefile.am index d981ecc..b4c3a37 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,12 @@ bin_SCRIPTS = postgresql$(DISTSUFF)-setup libexec_SCRIPTS = postgresql$(DISTSUFF)-ctl +pkgsysconfdir = $(PKGCONFIG_DIR) +pkgsysconf_DATA = conf/postgresql$(DISTSUFF) + +systemdunitsdir = $(prefix)/lib/systemd/system +systemdunits_DATA = postgresql$(DISTSUFF).service + config_status = $(top_srcdir)/config.status postgresql$(DISTSUFF)-ctl: postgresql-ctl.in @@ -14,4 +20,12 @@ postgresql$(DISTSUFF)-setup: postgresql-setup.in $(AM_V_GEN)cmd="$(config_status) --file=$@:$<" ; \ if $(AM_V_P); then $$cmd; else $$cmd &>/dev/null; fi && chmod +x $@ +conf/postgresql$(DISTSUFF): conf/postgresql.in + $(AM_V_GEN)cmd="$(config_status) --file=$@:$<" ; \ + if $(AM_V_P); then $$cmd; else $$cmd &>/dev/null; fi + +postgresql$(DISTSUFF).service: postgresql.service.in + $(AM_V_GEN)cmd="$(config_status) --file=$@:$<" ; \ + if $(AM_V_P); then $$cmd; else $$cmd &>/dev/null; fi + CLEANFILES = $(bin_SCRIPTS) $(libexec_SCRIPTS) diff --git a/conf/postgresql.in b/conf/postgresql.in new file mode 100644 index 0000000..057d4fb --- /dev/null +++ b/conf/postgresql.in @@ -0,0 +1,7 @@ +# Note: changing PGDATA will typically require adjusting SELinux configuration +# as well; see @README_DIST@. +# +# It is not encouraged to configure PGPORT here. Use the +# @PGDATADIR@/postgresql.conf configuration file. + +PGDATA=@PGDATADIR@ diff --git a/configure.ac b/configure.ac index 1a013ab..6acd497 100644 --- a/configure.ac +++ b/configure.ac @@ -120,8 +120,12 @@ test -z "$INITDB_LOG" && test -z "$UPGRADE_LOG" && UPGRADE_LOG=/var/lib/pgsql/pgupgrade.log -if test -z "$SYSCONFIG_DIR" -a "$distro_family" = redhat; then - SYSCONFIG_DIR=/etc/sysconfig +if test -z "$PKGCONFIG_DIR" -a "$distro_family" = redhat; then + PKGCONFIG_DIR=/etc/postgresql +fi + +if test -z "$PGDATADIR" -a "$distro_family" = redhat; then + PGDATADIR=/var/lib/pgsql/data fi # Deal with previous versions @@ -133,6 +137,7 @@ subst_required_var([PREVPGENGINE], [directory where old PG server resides]) subst_required_var([README_DIST], [README file for distribution]) subst_required_var([INITDB_LOG], [log file for initdb]) subst_required_var([UPGRADE_LOG], [log file for pg_upgrade]) -subst_required_var([SYSCONFIG_DIR], [log file for pg_upgrade]) +subst_required_var([PKGCONFIG_DIR], [where configuration should be stored]) +subst_required_var([PGDATADIR], [full path to postgres data dir]) AC_OUTPUT diff --git a/postgresql-setup.in b/postgresql-setup.in index bd96e09..0d78a69 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -30,7 +30,7 @@ PGLOG=@INITDB_LOG@ # Log file for pg_upgrade PGUPLOG=@UPGRADE_LOG@ -SYSCONFIG_DIR=@SYSCONFIG_DIR@ +SYSCONFIG_DIR=@PKGCONFIG_DIR@ SU=@SU@ diff --git a/postgresql.service b/postgresql.service deleted file mode 100644 index f390308..0000000 --- a/postgresql.service +++ /dev/null @@ -1,63 +0,0 @@ -# It's not recommended to modify this file in-place, because it will be -# overwritten during package upgrades. If you want to customize, the -# best way is to create a file "/etc/systemd/system/postgresql.service", -# containing -# .include /lib/systemd/system/postgresql.service -# ...make your changes here... -# For more info about custom unit files, see -# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F - -# For example, if you want to change the server's port number to 5433, -# create a file named "/etc/systemd/system/postgresql.service" containing: -# .include /lib/systemd/system/postgresql.service -# [Service] -# Environment=PGPORT=5433 -# This will override the setting appearing below. - -# Note: changing PGPORT or PGDATA will typically require adjusting SELinux -# configuration as well; see /usr/share/doc/postgresql/README.rpm-dist. - -# Note: do not use a PGDATA pathname containing spaces, or you will -# break postgresql-setup. - -# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line -# though /lib/... will still work. - -[Unit] -Description=PostgreSQL database server -After=network.target - -[Service] -Type=forking - -User=postgres -Group=postgres - -# Port number for server to listen on -Environment=PGPORT=5432 - -# Location of database directory -Environment=PGDATA=/var/lib/pgsql/data - -# Where to send early-startup messages from the server (before the logging -# options of postgresql.conf take effect) -# This is normally controlled by the global default set by systemd -# StandardOutput=syslog - -# Disable OOM kill on the postmaster -OOMScoreAdjust=-1000 -# ... but allow it still to be effective for child processes -# (note that these settings are ignored by Postgres releases before 9.5) -Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj -Environment=PG_OOM_ADJUST_VALUE=0 - -ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} -ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300 -ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast -ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s - -# Give a reasonable amount of time for the server to start up/shut down -TimeoutSec=300 - -[Install] -WantedBy=multi-user.target diff --git a/postgresql.service.in b/postgresql.service.in new file mode 100644 index 0000000..c865bcc --- /dev/null +++ b/postgresql.service.in @@ -0,0 +1,42 @@ +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to edit configuration file /etc/postgresql/$SERVICE_NAME +# (where by default, SERVICE_NAME is postgresql). + +[Unit] +Description=PostgreSQL database server +After=network.target + +[Service] +Type=forking + +User=postgres +Group=postgres + +EnvironmentFile=@PKGCONFIG_DIR@/%p + +# Where to send early-startup messages from the server (before the logging +# options of postgresql.conf take effect) +# This is normally controlled by the global default set by systemd +# StandardOutput=syslog + +# Disable OOM kill on the postmaster +OOMScoreAdjust=-1000 +# ... but allow it still to be effective for child processes +# (note that these settings are ignored by Postgres releases before 9.5) +Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj +Environment=PG_OOM_ADJUST_VALUE=0 + +ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} + +# Temporarily use postgresql-ctl wrapper around pg_ctl until there will +# exist clients which set PGPORT in service file. +ExecStart=@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t 300 +ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast +ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 + +[Install] +WantedBy=multi-user.target |