summaryrefslogtreecommitdiffstats
path: root/contrib/start-scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
commit293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch)
treefc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /contrib/start-scripts
parentInitial commit. (diff)
downloadpostgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz
postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/start-scripts')
-rw-r--r--contrib/start-scripts/freebsd66
-rw-r--r--contrib/start-scripts/linux124
-rw-r--r--contrib/start-scripts/macos/README24
-rw-r--r--contrib/start-scripts/macos/org.postgresql.postgres.plist17
-rw-r--r--contrib/start-scripts/macos/postgres-wrapper.sh25
5 files changed, 256 insertions, 0 deletions
diff --git a/contrib/start-scripts/freebsd b/contrib/start-scripts/freebsd
new file mode 100644
index 0000000..ed4f9ba
--- /dev/null
+++ b/contrib/start-scripts/freebsd
@@ -0,0 +1,66 @@
+#! /bin/sh
+
+# PostgreSQL boot time startup script for FreeBSD. Copy this file to
+# /usr/local/etc/rc.d/postgresql.
+
+# Created through merger of the Linux start script by Ryan Kirkpatrick
+# and the script in the FreeBSD ports collection.
+
+# contrib/start-scripts/freebsd
+
+## EDIT FROM HERE
+
+# Installation prefix
+prefix=/usr/local/pgsql
+
+# Data directory
+PGDATA="/usr/local/pgsql/data"
+
+# Who to run postgres as, usually "postgres". (NOT "root")
+PGUSER=postgres
+
+# Where to keep a log file
+PGLOG="$PGDATA/serverlog"
+
+## STOP EDITING HERE
+
+# The path that is to be used for the script
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+# What to use to start up postgres. (If you want the script to wait
+# until the server has started, you could use "pg_ctl start" here.)
+DAEMON="$prefix/bin/postgres"
+
+# What to use to shut down postgres
+PGCTL="$prefix/bin/pg_ctl"
+
+# Only start if we can find postgres.
+test -x $DAEMON ||
+{
+ echo "$DAEMON not found"
+ exit 0
+}
+
+case $1 in
+ start)
+ su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
+ echo -n ' postgresql'
+ ;;
+ stop)
+ su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
+ ;;
+ restart)
+ su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
+ su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
+ ;;
+ status)
+ su -l $PGUSER -c "$PGCTL status -D '$PGDATA'"
+ ;;
+ *)
+ # Print help
+ echo "Usage: `basename $0` {start|stop|restart|status}" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linux
new file mode 100644
index 0000000..ca01e96
--- /dev/null
+++ b/contrib/start-scripts/linux
@@ -0,0 +1,124 @@
+#! /bin/sh
+
+# chkconfig: 2345 98 02
+# description: PostgreSQL RDBMS
+
+# This is an example of a start/stop script for SysV-style init, such
+# as is used on Linux systems. You should edit some of the variables
+# and maybe the 'echo' commands.
+#
+# Place this file at /etc/init.d/postgresql (or
+# /etc/rc.d/init.d/postgresql) and make symlinks to
+# /etc/rc.d/rc0.d/K02postgresql
+# /etc/rc.d/rc1.d/K02postgresql
+# /etc/rc.d/rc2.d/K02postgresql
+# /etc/rc.d/rc3.d/S98postgresql
+# /etc/rc.d/rc4.d/S98postgresql
+# /etc/rc.d/rc5.d/S98postgresql
+# Or, if you have chkconfig, simply:
+# chkconfig --add postgresql
+#
+# Proper init scripts on Linux systems normally require setting lock
+# and pid files under /var/run as well as reacting to network
+# settings, so you should treat this with care.
+
+# Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net>
+
+# contrib/start-scripts/linux
+
+## EDIT FROM HERE
+
+# Installation prefix
+prefix=/usr/local/pgsql
+
+# Data directory
+PGDATA="/usr/local/pgsql/data"
+
+# Who to run postgres as, usually "postgres". (NOT "root")
+PGUSER=postgres
+
+# Where to keep a log file
+PGLOG="$PGDATA/serverlog"
+
+# It's often a good idea to protect the postmaster from being killed by the
+# OOM killer (which will tend to preferentially kill the postmaster because
+# of the way it accounts for shared memory). To do that, uncomment these
+# three lines:
+#PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
+#PG_MASTER_OOM_SCORE_ADJ=-1000
+#PG_CHILD_OOM_SCORE_ADJ=0
+# Older Linux kernels may not have /proc/self/oom_score_adj, but instead
+# /proc/self/oom_adj, which works similarly except for having a different
+# range of scores. For such a system, uncomment these three lines instead:
+#PG_OOM_ADJUST_FILE=/proc/self/oom_adj
+#PG_MASTER_OOM_SCORE_ADJ=-17
+#PG_CHILD_OOM_SCORE_ADJ=0
+
+## STOP EDITING HERE
+
+# The path that is to be used for the script
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+# What to use to start up postgres. (If you want the script to wait
+# until the server has started, you could use "pg_ctl start" here.)
+DAEMON="$prefix/bin/postgres"
+
+# What to use to shut down postgres
+PGCTL="$prefix/bin/pg_ctl"
+
+set -e
+
+# Only start if we can find postgres.
+test -x $DAEMON ||
+{
+ echo "$DAEMON not found"
+ if [ "$1" = "stop" ]
+ then exit 0
+ else exit 5
+ fi
+}
+
+# If we want to tell child processes to adjust their OOM scores, set up the
+# necessary environment variables. Can't just export them through the "su".
+if [ -e "$PG_OOM_ADJUST_FILE" -a -n "$PG_CHILD_OOM_SCORE_ADJ" ]
+then
+ DAEMON_ENV="PG_OOM_ADJUST_FILE=$PG_OOM_ADJUST_FILE PG_OOM_ADJUST_VALUE=$PG_CHILD_OOM_SCORE_ADJ"
+fi
+
+
+# Parse command line parameters.
+case $1 in
+ start)
+ echo -n "Starting PostgreSQL: "
+ test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
+ su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
+ echo "ok"
+ ;;
+ stop)
+ echo -n "Stopping PostgreSQL: "
+ su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
+ echo "ok"
+ ;;
+ restart)
+ echo -n "Restarting PostgreSQL: "
+ su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
+ test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
+ su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &"
+ echo "ok"
+ ;;
+ reload)
+ echo -n "Reload PostgreSQL: "
+ su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
+ echo "ok"
+ ;;
+ status)
+ su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
+ ;;
+ *)
+ # Print help
+ echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/contrib/start-scripts/macos/README b/contrib/start-scripts/macos/README
new file mode 100644
index 0000000..c4f2d9a
--- /dev/null
+++ b/contrib/start-scripts/macos/README
@@ -0,0 +1,24 @@
+To make macOS automatically launch your PostgreSQL server at system start,
+do the following:
+
+1. Edit the postgres-wrapper.sh script and adjust the file path
+variables at its start to reflect where you have installed Postgres,
+if that's not /usr/local/pgsql.
+
+2. Copy the modified postgres-wrapper.sh script into some suitable
+installation directory. It can be, but doesn't have to be, where
+you keep the Postgres executables themselves.
+
+3. Edit the org.postgresql.postgres.plist file and adjust its path
+for postgres-wrapper.sh to match what you did in step 2. Also,
+if you plan to run the Postgres server under some user name other
+than "postgres", adjust the UserName parameter value for that.
+
+4. Copy the modified org.postgresql.postgres.plist file into
+/Library/LaunchDaemons/. You must do this as root:
+ sudo cp org.postgresql.postgres.plist /Library/LaunchDaemons
+because the file will be ignored if it is not root-owned.
+
+At this point a reboot should launch the server. But if you want
+to test it without rebooting, you can do
+ sudo launchctl load /Library/LaunchDaemons/org.postgresql.postgres.plist
diff --git a/contrib/start-scripts/macos/org.postgresql.postgres.plist b/contrib/start-scripts/macos/org.postgresql.postgres.plist
new file mode 100644
index 0000000..fdbd74f
--- /dev/null
+++ b/contrib/start-scripts/macos/org.postgresql.postgres.plist
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>org.postgresql.postgres</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/bin/sh</string>
+ <string>/usr/local/pgsql/bin/postgres-wrapper.sh</string>
+ </array>
+ <key>UserName</key>
+ <string>postgres</string>
+ <key>KeepAlive</key>
+ <true/>
+</dict>
+</plist>
diff --git a/contrib/start-scripts/macos/postgres-wrapper.sh b/contrib/start-scripts/macos/postgres-wrapper.sh
new file mode 100644
index 0000000..3a4ebda
--- /dev/null
+++ b/contrib/start-scripts/macos/postgres-wrapper.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# PostgreSQL server start script (launched by org.postgresql.postgres.plist)
+
+# edit these as needed:
+
+# directory containing postgres executable:
+PGBINDIR="/usr/local/pgsql/bin"
+# data directory:
+PGDATA="/usr/local/pgsql/data"
+# file to receive postmaster's initial log messages:
+PGLOGFILE="${PGDATA}/pgstart.log"
+
+# (it's recommendable to enable the Postgres logging_collector feature
+# so that PGLOGFILE doesn't grow without bound)
+
+
+# set umask to ensure PGLOGFILE is not created world-readable
+umask 077
+
+# wait for networking to be up (else server may not bind to desired ports)
+/usr/sbin/ipconfig waitall
+
+# and launch the server
+exec "$PGBINDIR"/postgres -D "$PGDATA" >>"$PGLOGFILE" 2>&1