From 5d6126787ae19608d890b31f0e8db5e89beccb74 Mon Sep 17 00:00:00 2001 From: Borko Jandras Date: Thu, 22 Jun 2023 14:50:12 -0500 Subject: [PATCH] Installation/deinstallation scripts for RPM packages. (#216) --- dist/CMakeLists.txt | 12 ++++++++++++ dist/cloud-collector/rpm/post.sh | 5 +++++ dist/cloud-collector/rpm/postun.sh | 6 ++++++ dist/cloud-collector/rpm/preun.sh | 6 ++++++ dist/kernel-collector/rpm/post.sh | 5 +++++ dist/kernel-collector/rpm/postun.sh | 6 ++++++ dist/kernel-collector/rpm/preun.sh | 6 ++++++ dist/reducer/rpm/post.sh | 5 +++++ dist/reducer/rpm/postun.sh | 6 ++++++ dist/reducer/rpm/preun.sh | 6 ++++++ 10 files changed, 63 insertions(+) create mode 100644 dist/cloud-collector/rpm/post.sh create mode 100644 dist/cloud-collector/rpm/postun.sh create mode 100644 dist/cloud-collector/rpm/preun.sh create mode 100644 dist/kernel-collector/rpm/post.sh create mode 100644 dist/kernel-collector/rpm/postun.sh create mode 100644 dist/kernel-collector/rpm/preun.sh create mode 100644 dist/reducer/rpm/post.sh create mode 100644 dist/reducer/rpm/postun.sh create mode 100644 dist/reducer/rpm/preun.sh diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index 7cfad9f5..9a3ebc4b 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -20,6 +20,10 @@ set(CPACK_RPM_REDUCER_USER_FILELIST "%config(noreplace) ${CONFIG_DIR}/reducer.yaml" ) +set(CPACK_RPM_REDUCER_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/reducer/rpm/post.sh") +set(CPACK_RPM_REDUCER_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/reducer/rpm/preun.sh") +set(CPACK_RPM_REDUCER_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/reducer/rpm/postun.sh") + install( FILES reducer/reducer.service @@ -55,6 +59,10 @@ set(CPACK_RPM_KERNEL-COLLECTOR_USER_FILELIST "%config(noreplace) ${CONFIG_DIR}/kernel-collector.args" ) +set(CPACK_RPM_KERNEL-COLLECTOR_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/kernel-collector/rpm/post.sh") +set(CPACK_RPM_KERNEL-COLLECTOR_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/kernel-collector/rpm/preun.sh") +set(CPACK_RPM_KERNEL-COLLECTOR_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/kernel-collector/rpm/postun.sh") + install( FILES kernel-collector/kernel-collector.service @@ -87,6 +95,10 @@ set(CPACK_RPM_CLOUD-COLLECTOR_USER_FILELIST "%config(noreplace) ${CONFIG_DIR}/cloud-collector.args" ) +set(CPACK_RPM_CLOUD-COLLECTOR_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cloud-collector/rpm/post.sh") +set(CPACK_RPM_CLOUD-COLLECTOR_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cloud-collector/rpm/preun.sh") +set(CPACK_RPM_CLOUD-COLLECTOR_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cloud-collector/rpm/postun.sh") + install( FILES cloud-collector/cloud-collector.service diff --git a/dist/cloud-collector/rpm/post.sh b/dist/cloud-collector/rpm/post.sh new file mode 100644 index 00000000..39beca08 --- /dev/null +++ b/dist/cloud-collector/rpm/post.sh @@ -0,0 +1,5 @@ +service=cloud-collector.service +if [ $1 -eq 1 ]; then + # install + systemctl preset $service >/dev/null 2>&1 || : +fi diff --git a/dist/cloud-collector/rpm/postun.sh b/dist/cloud-collector/rpm/postun.sh new file mode 100644 index 00000000..b2d0dcc2 --- /dev/null +++ b/dist/cloud-collector/rpm/postun.sh @@ -0,0 +1,6 @@ +service=cloud-collector.service +systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ]; then + # upgrade + systemctl try-restart $service >/dev/null 2>&1 || : +fi diff --git a/dist/cloud-collector/rpm/preun.sh b/dist/cloud-collector/rpm/preun.sh new file mode 100644 index 00000000..a9174ff8 --- /dev/null +++ b/dist/cloud-collector/rpm/preun.sh @@ -0,0 +1,6 @@ +service=cloud-collector.service +if [ $1 -eq 0 ]; then + # uninstall + systemctl --no-reload disable $service > /dev/null 2>&1 || : + systemctl stop $service > /dev/null 2>&1 || : +fi diff --git a/dist/kernel-collector/rpm/post.sh b/dist/kernel-collector/rpm/post.sh new file mode 100644 index 00000000..e260d26a --- /dev/null +++ b/dist/kernel-collector/rpm/post.sh @@ -0,0 +1,5 @@ +service=kernel-collector.service +if [ $1 -eq 1 ]; then + # install + systemctl preset $service >/dev/null 2>&1 || : +fi diff --git a/dist/kernel-collector/rpm/postun.sh b/dist/kernel-collector/rpm/postun.sh new file mode 100644 index 00000000..bcaa14b0 --- /dev/null +++ b/dist/kernel-collector/rpm/postun.sh @@ -0,0 +1,6 @@ +service=kernel-collector.service +systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ]; then + # upgrade + systemctl try-restart $service >/dev/null 2>&1 || : +fi diff --git a/dist/kernel-collector/rpm/preun.sh b/dist/kernel-collector/rpm/preun.sh new file mode 100644 index 00000000..7ba01265 --- /dev/null +++ b/dist/kernel-collector/rpm/preun.sh @@ -0,0 +1,6 @@ +service=kernel-collector.service +if [ $1 -eq 0 ]; then + # uninstall + systemctl --no-reload disable $service > /dev/null 2>&1 || : + systemctl stop $service > /dev/null 2>&1 || : +fi diff --git a/dist/reducer/rpm/post.sh b/dist/reducer/rpm/post.sh new file mode 100644 index 00000000..731bf2e1 --- /dev/null +++ b/dist/reducer/rpm/post.sh @@ -0,0 +1,5 @@ +service=reducer.service +if [ $1 -eq 1 ]; then + # install + systemctl preset $service >/dev/null 2>&1 || : +fi diff --git a/dist/reducer/rpm/postun.sh b/dist/reducer/rpm/postun.sh new file mode 100644 index 00000000..04ec0e04 --- /dev/null +++ b/dist/reducer/rpm/postun.sh @@ -0,0 +1,6 @@ +service=reducer.service +systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ]; then + # upgrade + systemctl try-restart $service >/dev/null 2>&1 || : +fi diff --git a/dist/reducer/rpm/preun.sh b/dist/reducer/rpm/preun.sh new file mode 100644 index 00000000..588f8b01 --- /dev/null +++ b/dist/reducer/rpm/preun.sh @@ -0,0 +1,6 @@ +service=reducer.service +if [ $1 -eq 0 ]; then + # uninstall + systemctl --no-reload disable $service > /dev/null 2>&1 || : + systemctl stop $service > /dev/null 2>&1 || : +fi