Update src/pgpool.spec:
authorBo Peng <pengbo@sraoss.co.jp>
Sat, 5 Nov 2022 03:42:11 +0000 (12:42 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Sat, 5 Nov 2022 03:42:11 +0000 (12:42 +0900)
- Change /lib/tmpfiles.d/ file from /var/run to /run
- Install /etc/sudoers.d/pgpool
- Add new scripts aws_eip_if_cmd.sh.sample and aws_rtb_if_cmd.sh.sample

src/Makefile.am
src/Makefile.in
src/pgpool.spec
src/redhat/pgpool_socket_dir.patch
src/redhat/pgpool_sudoers.d [new file with mode: 0644]
src/redhat/pgpool_tmpfiles.d [new file with mode: 0644]

index ba2358f59146fe496b8e71085664ea1f2ab8b927..fa2693ad724ef4e06a86a20e35ebedf270d834c8 100644 (file)
@@ -78,7 +78,9 @@ sysconf_DATA = sample/pgpool.conf.sample \
                           sample/scripts/recovery_1st_stage.sample \
                           sample/scripts/replication_mode_recovery_1st_stage.sample \
                           sample/scripts/replication_mode_recovery_2nd_stage.sample \
-                          sample/scripts/escalation.sh.sample
+                          sample/scripts/escalation.sh.sample \
+                          sample/scripts/aws_eip_if_cmd.sh.sample \
+                          sample/scripts/aws_rtb_if_cmd.sh.sample
 
 
 pkgdata_DATA = sql/insert_lock.sql \
@@ -107,6 +109,8 @@ EXTRA_DIST = sample/pgpool.pam \
                sample/scripts/replication_mode_recovery_1st_stage.sample \
                sample/scripts/replication_mode_recovery_2nd_stage.sample \
                sample/scripts/escalation.sh.sample \
+               sample/scripts/aws_eip_if_cmd.sh.sample \
+               sample/scripts/aws_rtb_if_cmd.sh.sample \
                sample/pgpool.conf.sample sample/pool_hba.conf.sample \
                sample/pcp.conf.sample \
                sql/Makefile \
index d3c5c3106021a8bc3f024f1f0d59223ab65cfdfb..55eec878e5945d2f82619476e85f4935a456e2ff 100644 (file)
@@ -507,7 +507,9 @@ sysconf_DATA = sample/pgpool.conf.sample \
                           sample/scripts/recovery_1st_stage.sample \
                           sample/scripts/replication_mode_recovery_1st_stage.sample \
                           sample/scripts/replication_mode_recovery_2nd_stage.sample \
-                          sample/scripts/escalation.sh.sample
+                          sample/scripts/escalation.sh.sample \
+                          sample/scripts/aws_eip_if_cmd.sh.sample \
+                          sample/scripts/aws_rtb_if_cmd.sh.sample
 
 pkgdata_DATA = sql/insert_lock.sql \
                           sample/pgpool.pam
@@ -531,6 +533,8 @@ EXTRA_DIST = sample/pgpool.pam \
                sample/scripts/replication_mode_recovery_1st_stage.sample \
                sample/scripts/replication_mode_recovery_2nd_stage.sample \
                sample/scripts/escalation.sh.sample \
+               sample/scripts/aws_eip_if_cmd.sh.sample \
+               sample/scripts/aws_rtb_if_cmd.sh.sample \
                sample/pgpool.conf.sample sample/pool_hba.conf.sample \
                sample/pcp.conf.sample \
                sql/Makefile \
index e77472f0206eff0bce836852cfae7001f02eee3a..1b230cf0173cf035d73a03e3ca4701d50c23aabf 100644 (file)
@@ -1,10 +1,10 @@
 # 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
@@ -38,6 +38,8 @@ Source2:        pgpool_rhel6.sysconfig
 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
@@ -134,6 +136,25 @@ make %{?_smp_mflags} DESTDIR=%{buildroot} install -C src/sql/pgpool_adm
 
 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
@@ -145,9 +166,7 @@ install -d %{buildroot}%{_unitdir}
 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
@@ -162,6 +181,10 @@ install -d %{buildroot}%{_sysconfdir}/sysconfig
     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}
 
@@ -184,8 +207,6 @@ useradd -M -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
 
 %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
@@ -258,6 +279,7 @@ fi
 %if %{systemd_enabled}
 %ghost %{_varrundir}
 %{_tmpfilesdir}/%{name}.conf
+%{_sysconfdir}/sudoers.d/pgpool
 %{_unitdir}/pgpool.service
 %else
 %{_initrddir}/pgpool
@@ -268,13 +290,15 @@ fi
 %{_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
@@ -329,6 +353,11 @@ fi
 %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
 
index 196af8d4af4a49ccb286fb15ed3745dd5bceef3e..986eefdae33cfd19713fb090a8e9a595bd16eb43 100644 (file)
@@ -1,24 +1,24 @@
-*** 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)
@@ -26,7 +26,7 @@
                                      # 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)
@@ -35,7 +35,7 @@
                                      # The Debian package defaults to
                                      # /var/run/postgresql
 ***************
-*** 676,682 ****
+*** 687,693 ****
                                       # Authentication key for watchdog communication
                                       # (change requires restart)
   
@@ -43,7 +43,7 @@
                                       # 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)
   
diff --git a/src/redhat/pgpool_sudoers.d b/src/redhat/pgpool_sudoers.d
new file mode 100644 (file)
index 0000000..e81c665
--- /dev/null
@@ -0,0 +1,2 @@
+postgres ALL=NOPASSWD: /sbin/ip
+postgres ALL=NOPASSWD: /usr/sbin/arping
diff --git a/src/redhat/pgpool_tmpfiles.d b/src/redhat/pgpool_tmpfiles.d
new file mode 100644 (file)
index 0000000..145e56a
--- /dev/null
@@ -0,0 +1 @@
+d /run/pgpool 0755 postgres postgres -