Last active
March 10, 2024 14:33
-
-
Save jrjsmrtn/3bc40007778d2002b8f520498f56fa54 to your computer and use it in GitHub Desktop.
Publish PostgreSQL Cluster service using avahi-publish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=Avahi Service Publisher for PostgreSQL Cluster %i | |
| AssertPathExists=/etc/postgresql/%I/postgresql.conf | |
| AssertFileIsExecutable=/usr/bin/avahi-publish-service | |
| Wants=postgresql@%i.service | |
| After=postgresql@%i.service | |
| BindsTo=postgresql@%i.service | |
| [Service] | |
| Environment="N=%i" | |
| Environment="T=_postgresql._tcp" | |
| Environment="PUBLISH=/usr/bin/avahi-publish-service" | |
| ExecCondition=/bin/bash -c \ | |
| 'LA="$(pg_conftool ${N/-/ } show --short listen_addresses)"; [ "$LA" = "*" ]' | |
| ExecStart=/bin/bash -c \ | |
| 'P="$(pg_conftool ${N/-/ } show --short port)"; $PUBLISH "PostgreSQL Cluster %I @ %H" $T $P' | |
| [Install] | |
| WantedBy=postgresql@%i.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment