From 22994bb8694b8aa8b1094f1e7f24f499816fa1a4 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 26 May 2025 21:17:15 +0200 Subject: [PATCH] Add postgresql --- rc.postgresql/postgresql-log/consumer-for | 1 + rc.postgresql/postgresql-log/dependencies | 4 ++++ rc.postgresql/postgresql-log/env/CMD | 1 + rc.postgresql/postgresql-log/env/CMD_OPTS | 1 + rc.postgresql/postgresql-log/env/LOGDIR_GROUP | 2 ++ rc.postgresql/postgresql-log/env/LOGDIR_OWNER | 2 ++ rc.postgresql/postgresql-log/env/LOGDIR_PATH | 2 ++ rc.postgresql/postgresql-log/env/LOGDIR_PERMS | 2 ++ rc.postgresql/postgresql-log/env/LOG_SCRIPT | 2 ++ rc.postgresql/postgresql-log/notification-fd | 1 + rc.postgresql/postgresql-log/pipeline-name | 1 + rc.postgresql/postgresql-log/run | 24 +++++++++++++++++++ rc.postgresql/postgresql-log/type | 1 + rc.postgresql/postgresql-srv/data/check | 7 ++++++ rc.postgresql/postgresql-srv/dependencies | 6 +++++ rc.postgresql/postgresql-srv/down-signal | 1 + rc.postgresql/postgresql-srv/env/CMD | 1 + rc.postgresql/postgresql-srv/env/CMD_OPTS | 1 + .../postgresql-srv/env/PG_OOM_ADJUST_FILE | 1 + .../postgresql-srv/env/PG_OOM_ADJUST_VALUE | 1 + rc.postgresql/postgresql-srv/env/PG_VERSION | 1 + rc.postgresql/postgresql-srv/notification-fd | 1 + rc.postgresql/postgresql-srv/producer-for | 1 + rc.postgresql/postgresql-srv/run | 23 ++++++++++++++++++ rc.postgresql/postgresql-srv/type | 1 + 25 files changed, 89 insertions(+) create mode 100644 rc.postgresql/postgresql-log/consumer-for create mode 100644 rc.postgresql/postgresql-log/dependencies create mode 100644 rc.postgresql/postgresql-log/env/CMD create mode 100644 rc.postgresql/postgresql-log/env/CMD_OPTS create mode 100644 rc.postgresql/postgresql-log/env/LOGDIR_GROUP create mode 100644 rc.postgresql/postgresql-log/env/LOGDIR_OWNER create mode 100644 rc.postgresql/postgresql-log/env/LOGDIR_PATH create mode 100644 rc.postgresql/postgresql-log/env/LOGDIR_PERMS create mode 100644 rc.postgresql/postgresql-log/env/LOG_SCRIPT create mode 100644 rc.postgresql/postgresql-log/notification-fd create mode 100644 rc.postgresql/postgresql-log/pipeline-name create mode 100644 rc.postgresql/postgresql-log/run create mode 100644 rc.postgresql/postgresql-log/type create mode 100755 rc.postgresql/postgresql-srv/data/check create mode 100644 rc.postgresql/postgresql-srv/dependencies create mode 100644 rc.postgresql/postgresql-srv/down-signal create mode 100644 rc.postgresql/postgresql-srv/env/CMD create mode 100644 rc.postgresql/postgresql-srv/env/CMD_OPTS create mode 100644 rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_FILE create mode 100644 rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_VALUE create mode 100644 rc.postgresql/postgresql-srv/env/PG_VERSION create mode 100644 rc.postgresql/postgresql-srv/notification-fd create mode 100644 rc.postgresql/postgresql-srv/producer-for create mode 100644 rc.postgresql/postgresql-srv/run create mode 100644 rc.postgresql/postgresql-srv/type diff --git a/rc.postgresql/postgresql-log/consumer-for b/rc.postgresql/postgresql-log/consumer-for new file mode 100644 index 0000000..7ab98b6 --- /dev/null +++ b/rc.postgresql/postgresql-log/consumer-for @@ -0,0 +1 @@ +postgresql-srv diff --git a/rc.postgresql/postgresql-log/dependencies b/rc.postgresql/postgresql-log/dependencies new file mode 100644 index 0000000..e85efae --- /dev/null +++ b/rc.postgresql/postgresql-log/dependencies @@ -0,0 +1,4 @@ +# Comment out "remount-root" and uncomment "local-fs" +# if you use separate partition for /var/log +remount-root +#local-fs diff --git a/rc.postgresql/postgresql-log/env/CMD b/rc.postgresql/postgresql-log/env/CMD new file mode 100644 index 0000000..9d5239c --- /dev/null +++ b/rc.postgresql/postgresql-log/env/CMD @@ -0,0 +1 @@ +s6-log diff --git a/rc.postgresql/postgresql-log/env/CMD_OPTS b/rc.postgresql/postgresql-log/env/CMD_OPTS new file mode 100644 index 0000000..00d672e --- /dev/null +++ b/rc.postgresql/postgresql-log/env/CMD_OPTS @@ -0,0 +1 @@ +-d3 diff --git a/rc.postgresql/postgresql-log/env/LOGDIR_GROUP b/rc.postgresql/postgresql-log/env/LOGDIR_GROUP new file mode 100644 index 0000000..3794bcd --- /dev/null +++ b/rc.postgresql/postgresql-log/env/LOGDIR_GROUP @@ -0,0 +1,2 @@ +root +# Logging directory group ownership diff --git a/rc.postgresql/postgresql-log/env/LOGDIR_OWNER b/rc.postgresql/postgresql-log/env/LOGDIR_OWNER new file mode 100644 index 0000000..9f9fd12 --- /dev/null +++ b/rc.postgresql/postgresql-log/env/LOGDIR_OWNER @@ -0,0 +1,2 @@ +root +# Logging directory owner diff --git a/rc.postgresql/postgresql-log/env/LOGDIR_PATH b/rc.postgresql/postgresql-log/env/LOGDIR_PATH new file mode 100644 index 0000000..bac038b --- /dev/null +++ b/rc.postgresql/postgresql-log/env/LOGDIR_PATH @@ -0,0 +1,2 @@ +/var/log/postgresql +# Logging directory path diff --git a/rc.postgresql/postgresql-log/env/LOGDIR_PERMS b/rc.postgresql/postgresql-log/env/LOGDIR_PERMS new file mode 100644 index 0000000..ccece6e --- /dev/null +++ b/rc.postgresql/postgresql-log/env/LOGDIR_PERMS @@ -0,0 +1,2 @@ +750 +# Logging directory access rights in octal diff --git a/rc.postgresql/postgresql-log/env/LOG_SCRIPT b/rc.postgresql/postgresql-log/env/LOG_SCRIPT new file mode 100644 index 0000000..017b42c --- /dev/null +++ b/rc.postgresql/postgresql-log/env/LOG_SCRIPT @@ -0,0 +1,2 @@ +n4 s500000 $LOGDIR_PATH +# Logging script used by s6-log diff --git a/rc.postgresql/postgresql-log/notification-fd b/rc.postgresql/postgresql-log/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/rc.postgresql/postgresql-log/notification-fd @@ -0,0 +1 @@ +3 diff --git a/rc.postgresql/postgresql-log/pipeline-name b/rc.postgresql/postgresql-log/pipeline-name new file mode 100644 index 0000000..a02a1cc --- /dev/null +++ b/rc.postgresql/postgresql-log/pipeline-name @@ -0,0 +1 @@ +postgresql diff --git a/rc.postgresql/postgresql-log/run b/rc.postgresql/postgresql-log/run new file mode 100644 index 0000000..7628e26 --- /dev/null +++ b/rc.postgresql/postgresql-log/run @@ -0,0 +1,24 @@ +#!/bin/execlineb -P + +#################################################### +# Start a logging daemon for the postgresql daemon # +#################################################### + +s6-envdir env +multisubstitute { + importas -u LOGDIR_OWNER LOGDIR_OWNER + importas -u LOGDIR_GROUP LOGDIR_GROUP + importas -u LOGDIR_PERMS LOGDIR_PERMS + importas -u CMD CMD + importas -usCd" " CMD_OPTS CMD_OPTS + importas -usCd" " LOG_SCRIPT LOG_SCRIPT +} +s6-envuidgid -B ${LOGDIR_OWNER}:${LOGDIR_GROUP} +multisubstitute { + importas -u LOGDIR_PATH LOGDIR_PATH + importas -u UID UID + importas -u GID GID +} +if { install -dm $LOGDIR_PERMS -o $UID -g $GID $LOGDIR_PATH } +s6-setuidgid ${UID}:${GID} +exec -c $CMD $CMD_OPTS -- $LOG_SCRIPT diff --git a/rc.postgresql/postgresql-log/type b/rc.postgresql/postgresql-log/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rc.postgresql/postgresql-log/type @@ -0,0 +1 @@ +longrun diff --git a/rc.postgresql/postgresql-srv/data/check b/rc.postgresql/postgresql-srv/data/check new file mode 100755 index 0000000..bc8bb10 --- /dev/null +++ b/rc.postgresql/postgresql-srv/data/check @@ -0,0 +1,7 @@ +#!/bin/execlineb -P + +s6-envdir env +importas -u PG_VERSION PG_VERSION +pipeline { tail -n1 /var/lib/pgsql/${PG_VERSION}/data/postmaster.pid } +pipeline { tr -d " \n" } +xargs test ready = diff --git a/rc.postgresql/postgresql-srv/dependencies b/rc.postgresql/postgresql-srv/dependencies new file mode 100644 index 0000000..bf84970 --- /dev/null +++ b/rc.postgresql/postgresql-srv/dependencies @@ -0,0 +1,6 @@ +procfs +network +# Comment out "remount-root" and uncomment "local-fs" +# if you use separate partition for /var +#remount-root +local-fs diff --git a/rc.postgresql/postgresql-srv/down-signal b/rc.postgresql/postgresql-srv/down-signal new file mode 100644 index 0000000..d751378 --- /dev/null +++ b/rc.postgresql/postgresql-srv/down-signal @@ -0,0 +1 @@ +SIGINT diff --git a/rc.postgresql/postgresql-srv/env/CMD b/rc.postgresql/postgresql-srv/env/CMD new file mode 100644 index 0000000..ebd1610 --- /dev/null +++ b/rc.postgresql/postgresql-srv/env/CMD @@ -0,0 +1 @@ +/usr/lib64/postgresql/${PG_VERSION}/bin/postgres diff --git a/rc.postgresql/postgresql-srv/env/CMD_OPTS b/rc.postgresql/postgresql-srv/env/CMD_OPTS new file mode 100644 index 0000000..ebe0e69 --- /dev/null +++ b/rc.postgresql/postgresql-srv/env/CMD_OPTS @@ -0,0 +1 @@ +-D /var/lib/pgsql/${PG_VERSION}/data diff --git a/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_FILE b/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_FILE new file mode 100644 index 0000000..ab41318 --- /dev/null +++ b/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_FILE @@ -0,0 +1 @@ +/proc/self/oom_score_adj diff --git a/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_VALUE b/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_VALUE new file mode 100644 index 0000000..573541a --- /dev/null +++ b/rc.postgresql/postgresql-srv/env/PG_OOM_ADJUST_VALUE @@ -0,0 +1 @@ +0 diff --git a/rc.postgresql/postgresql-srv/env/PG_VERSION b/rc.postgresql/postgresql-srv/env/PG_VERSION new file mode 100644 index 0000000..8351c19 --- /dev/null +++ b/rc.postgresql/postgresql-srv/env/PG_VERSION @@ -0,0 +1 @@ +14 diff --git a/rc.postgresql/postgresql-srv/notification-fd b/rc.postgresql/postgresql-srv/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/rc.postgresql/postgresql-srv/notification-fd @@ -0,0 +1 @@ +3 diff --git a/rc.postgresql/postgresql-srv/producer-for b/rc.postgresql/postgresql-srv/producer-for new file mode 100644 index 0000000..ffe5b68 --- /dev/null +++ b/rc.postgresql/postgresql-srv/producer-for @@ -0,0 +1 @@ +postgresql-log diff --git a/rc.postgresql/postgresql-srv/run b/rc.postgresql/postgresql-srv/run new file mode 100644 index 0000000..2aa341d --- /dev/null +++ b/rc.postgresql/postgresql-srv/run @@ -0,0 +1,23 @@ +#!/bin/execlineb -P + +################################################################### +# Start PostgreSQL (object-relational database management system) # +################################################################### + +fdmove -c 2 1 +getpid PID +s6-envdir env +multisubstitute { + importas -u PID PID + importas -u CMD CMD + importas -usCd" " CMD_OPTS CMD_OPTS +} +importas -u PG_VERSION PG_VERSION +foreground { + if { test -e /proc/${PID}/oom_score_adj } + redirfd -w 1 /proc/${PID}/oom_score_adj + echo -1000 +} +s6-notifyoncheck +s6-setuidgid postgres +exec -c $CMD $CMD_OPTS diff --git a/rc.postgresql/postgresql-srv/type b/rc.postgresql/postgresql-srv/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rc.postgresql/postgresql-srv/type @@ -0,0 +1 @@ +longrun