# How to build RPM:
#
-# rpmbuild -ba pgpool.spec --define="pgpool_version 3.4.0" --define="pg_version 93" --define="pghome /usr/pgsql-9.3" --define="dist .rhel6" --define="pgsql_ver 93"
+# rpmbuild -ba pgpool.spec --define="pgpool_version 3.4.0" --define="pg_version 93" --define="pghome /usr/pgsql-9.3" --define="dist .rhel7" --define="pgsql_ver 93"
#
# OR
#
-# rpmbuild -ba pgpool.spec --define="pgpool_version 3.4.0" --define="pg_version 11" --define="pghome /usr/pgsql-11" --define="dist .rhel6" --define="pgsql_ver 110"
+# rpmbuild -ba pgpool.spec --define="pgpool_version 3.4.0" --define="pg_version 11" --define="pghome /usr/pgsql-11" --define="dist .rhel7" --define="pgsql_ver 110"
#
# expecting RPM name are:
# pgpool-II-pg{pg_version}-{pgpool_version}-{rel}pgdg.rhel{v}.{arch}.rpm
Source3: pgpool.service
%endif
Source4: pgpool_rhel.sysconfig
+Source5: pgpool_tmpfiles.d
+Source6: pgpool_sudoers.d
Patch1: pgpool-II-head.patch
%if %{pgsql_ver} >=94 && %{rhel} >= 7
Patch2: pgpool_socket_dir.patch
install -d %{buildroot}%{_datadir}/%{short_name}
install -d %{buildroot}%{_sysconfdir}/%{short_name}
+install -d %{buildroot}%{_sysconfdir}/%{short_name}/scripts
+mv %{buildroot}%{_sysconfdir}/%{short_name}/failover.sh.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/failover.sh.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/follow_primary.sh.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/follow_primary.sh.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/pgpool_remote_start.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/pgpool_remote_start.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/recovery_1st_stage.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/recovery_1st_stage.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/replication_mode_recovery_1st_stage.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/replication_mode_recovery_1st_stage.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/replication_mode_recovery_2nd_stage.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/replication_mode_recovery_2nd_stage.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/escalation.sh.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/escalation.sh.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/aws_eip_if_cmd.sh.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/aws_eip_if_cmd.sh.sample
+mv %{buildroot}%{_sysconfdir}/%{short_name}/aws_rtb_if_cmd.sh.sample \
+ %{buildroot}%{_sysconfdir}/%{short_name}/scripts/aws_rtb_if_cmd.sh.sample
cp %{buildroot}%{_sysconfdir}/%{short_name}/pcp.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pcp.conf
cp %{buildroot}%{_sysconfdir}/%{short_name}/pgpool.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pgpool.conf
cp %{buildroot}%{_sysconfdir}/%{short_name}/pool_hba.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pool_hba.conf
install -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/pgpool.service
mkdir -p %{buildroot}%{_tmpfilesdir}
-cat > %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
-d %{_varrundir} 0755 postgres postgres -
-EOF
+install -m 0644 %{SOURCE5} %{buildroot}%{_tmpfilesdir}/%{name}.conf
%else
install -d %{buildroot}%{_initrddir}
install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/pgpool
install -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/pgpool
%endif
+# install sudoers.d to allow postgres user to run ip and arping with root privileges without a password
+install -d %{buildroot}%{_sysconfdir}/sudoers.d
+install -m 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sudoers.d/pgpool
+
# nuke libtool archive and static lib
rm -f %{buildroot}%{_libdir}/libpcp.{a,la}
%post
/sbin/ldconfig
-echo 'postgres ALL=NOPASSWD: /sbin/ip' | sudo EDITOR='tee -a' visudo >/dev/null 2>&1 || :
-echo 'postgres ALL=NOPASSWD: /usr/sbin/arping' | sudo EDITOR='tee -a' visudo >/dev/null 2>&1 || :
%if %{systemd_enabled}
%systemd_post pgpool.service
%if %{systemd_enabled}
%ghost %{_varrundir}
%{_tmpfilesdir}/%{name}.conf
+%{_sysconfdir}/sudoers.d/pgpool
%{_unitdir}/pgpool.service
%else
%{_initrddir}/pgpool
%{_sysconfdir}/%{short_name}/pcp.conf.sample
%{_sysconfdir}/%{short_name}/pool_hba.conf.sample
%defattr(755,postgres,postgres,-)
-%{_sysconfdir}/%{short_name}/failover.sh.sample
-%{_sysconfdir}/%{short_name}/follow_primary.sh.sample
-%{_sysconfdir}/%{short_name}/pgpool_remote_start.sample
-%{_sysconfdir}/%{short_name}/recovery_1st_stage.sample
-%{_sysconfdir}/%{short_name}/replication_mode_recovery_1st_stage.sample
-%{_sysconfdir}/%{short_name}/replication_mode_recovery_2nd_stage.sample
-%{_sysconfdir}/%{short_name}/escalation.sh.sample
+%{_sysconfdir}/%{short_name}/scripts/failover.sh.sample
+%{_sysconfdir}/%{short_name}/scripts/follow_primary.sh.sample
+%{_sysconfdir}/%{short_name}/scripts/pgpool_remote_start.sample
+%{_sysconfdir}/%{short_name}/scripts/recovery_1st_stage.sample
+%{_sysconfdir}/%{short_name}/scripts/replication_mode_recovery_1st_stage.sample
+%{_sysconfdir}/%{short_name}/scripts/replication_mode_recovery_2nd_stage.sample
+%{_sysconfdir}/%{short_name}/scripts/escalation.sh.sample
+%{_sysconfdir}/%{short_name}/scripts/aws_eip_if_cmd.sh.sample
+%{_sysconfdir}/%{short_name}/scripts/aws_rtb_if_cmd.sh.sample
%attr(600,postgres,postgres) %config(noreplace) %{_sysconfdir}/%{short_name}/*.conf
%attr(600,postgres,postgres) %config(noreplace) %{_sysconfdir}/%{short_name}/pool_passwd
%attr(600,postgres,postgres) %config(noreplace) %{_sysconfdir}/%{short_name}/pgpool_node_id
%endif
%changelog
+* Wed Nov 2 2022 Bo Peng <pengbo@sraoss.co.jp> 4.4.0
+- Change /lib/tmpfiles.d/ file from /var/run to /run
+- Install /etc/sudoers.d/pgpool
+- Add scripts aws_eip_if_cmd.sh.sample and aws_rtb_if_cmd.sh.sample
+
* Thu Sep 10 2020 Bo Peng <pengbo@sraoss.co.jp> 4.2.0
- Update to 4.2
-*** src/sample/pgpool.conf.sample 2021-11-08 15:00:32.984579019 +0900
---- pgpool.conf.sample 2021-11-08 17:14:44.456058528 +0900
+*** src/sample/pgpool.conf.sample 2022-11-02 13:03:37.123808571 +0900
+--- pgpool.conf.sample 2022-11-04 13:35:43.081669422 +0900
***************
*** 39,45 ****
#port = 9999
# Port number
# (change requires restart)
-! #socket_dir = '/tmp'
- # Unix domain socket path
+! #unix_socket_directories = '/tmp'
+ # Unix domain socket path(s)
# The Debian package defaults to
# /var/run/postgresql
--- 39,45 ----
#port = 9999
# Port number
# (change requires restart)
-! socket_dir = '/var/run/postgresql'
- # Unix domain socket path
+! unix_socket_directories = '/var/run/postgresql'
+ # Unix domain socket path(s)
# The Debian package defaults to
# /var/run/postgresql
***************
-*** 59,65 ****
+*** 65,71 ****
#pcp_port = 9898
# Port number for pcp
# (change requires restart)
# Unix domain socket path for pcp
# The Debian package defaults to
# /var/run/postgresql
---- 59,65 ----
+--- 65,71 ----
#pcp_port = 9898
# Port number for pcp
# (change requires restart)
# The Debian package defaults to
# /var/run/postgresql
***************
-*** 676,682 ****
+*** 687,693 ****
# Authentication key for watchdog communication
# (change requires restart)
# Unix domain socket path for watchdog IPC socket
# The Debian package defaults to
# /var/run/postgresql
---- 676,682 ----
+--- 687,693 ----
# Authentication key for watchdog communication
# (change requires restart)