From 5db1ed2bafbaa5b1b5852117469d7a665efc13c5 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 6 Sep 2018 14:20:30 +0200 Subject: [PATCH] postgres uid tryfix --- lxc-build | 2 +- postgres/lxc/etc/services.d/.s6-svscan/finish | 3 +++ postgres/lxc/etc/services.d/postgres/run | 5 +++++ postgres/lxcfile | 3 +-- postgres/setup.sh | 2 +- postgres/setup/etc/init.d/postgres | 2 +- postgres/setup/srv/postgres/data/postgresql.conf | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) create mode 100755 postgres/lxc/etc/services.d/.s6-svscan/finish create mode 100755 postgres/lxc/etc/services.d/postgres/run diff --git a/lxc-build b/lxc-build index c8b0b00..4190d2a 100755 --- a/lxc-build +++ b/lxc-build @@ -84,7 +84,7 @@ class LXCImage: uidgid = line.split() self.set_user(uidgid[1], uidgid[2]) elif line.startswith('CMD'): - self.set_cmd(line.split()[1]) + self.set_cmd(' '.join(line.split()[1:])) # Add the final layer which can be treated as nonpersistent self.add_layer('{}/delta0'.format(self.name)) diff --git a/postgres/lxc/etc/services.d/.s6-svscan/finish b/postgres/lxc/etc/services.d/.s6-svscan/finish new file mode 100755 index 0000000..78d5fdc --- /dev/null +++ b/postgres/lxc/etc/services.d/.s6-svscan/finish @@ -0,0 +1,3 @@ +#!/bin/sh + +/bin/true diff --git a/postgres/lxc/etc/services.d/postgres/run b/postgres/lxc/etc/services.d/postgres/run new file mode 100755 index 0000000..92284df --- /dev/null +++ b/postgres/lxc/etc/services.d/postgres/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P + +fdmove -c 2 1 +s6-setuidgid 5432:5432 +/usr/bin/postgres -D /var/lib/postgresql diff --git a/postgres/lxcfile b/postgres/lxcfile index f1ae629..01afcb3 100644 --- a/postgres/lxcfile +++ b/postgres/lxcfile @@ -20,5 +20,4 @@ RUN MOUNT /srv/postgres/data var/lib/postgresql -USER 5432 5432 -CMD postgres -D /var/lib/postgresql +CMD s6-svscan /etc/services.d diff --git a/postgres/setup.sh b/postgres/setup.sh index 405e399..cfdc42f 100755 --- a/postgres/setup.sh +++ b/postgres/setup.sh @@ -7,7 +7,7 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/setup mkdir -p /srv/postgres/data chown -R 5432:5432 /srv/postgres/data chmod 700 /srv/postgres/data -lxc-execute -n postgres -- sh -lc 'initdb -D /var/lib/postgresql' +lxc-execute -n postgres -- /usr/bin/initdb -D /var/lib/postgresql # Configure Postgres cp ${SOURCE_DIR}/srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf diff --git a/postgres/setup/etc/init.d/postgres b/postgres/setup/etc/init.d/postgres index 3e83ad9..3370955 100755 --- a/postgres/setup/etc/init.d/postgres +++ b/postgres/setup/etc/init.d/postgres @@ -11,7 +11,7 @@ start() { } start_post() { - ewaitfile 60 /var/lib/lxc/postgres/delta0/var/run/postgresql/.s.PGSQL.5432 + ewaitfile 60 /var/lib/lxc/postgres/delta0/run/postgresql/.s.PGSQL.5432 } stop() { diff --git a/postgres/setup/srv/postgres/data/postgresql.conf b/postgres/setup/srv/postgres/data/postgresql.conf index bec8b6b..fd0d697 100644 --- a/postgres/setup/srv/postgres/data/postgresql.conf +++ b/postgres/setup/srv/postgres/data/postgresql.conf @@ -63,7 +63,7 @@ listen_addresses = '*' # what IP address(es) to listen on; #port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) -unix_socket_directories = '/run/postgresql,/tmp' # comma-separated list of directories +unix_socket_directories = '/run/postgresql' # comma-separated list of directories # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation