MXS-2969: Restart MaxScale on upgrade
Renamed the postrm script to prerm since it is executed before uninstallation. Silenced the output of the systemctl disable commands and added a conditional restart of MaxScale if a MaxScale instance is running. Use getent instead of grep to detect if the maxscale user needs to be created.
This commit is contained in:
parent
c3ddcb9056
commit
be567b6029
@ -119,7 +119,7 @@ configure_file(${CMAKE_SOURCE_DIR}/include/maxscale/paths.h.in ${CMAKE_BINARY_DI
|
||||
configure_file(${CMAKE_SOURCE_DIR}/include/maxscale/adminusers.h.in ${CMAKE_BINARY_DIR}/include/maxscale/adminusers.h @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY_DIR}/include/maxscale/maxscale_test.h @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postinst.in ${CMAKE_BINARY_DIR}/postinst @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postrm.in ${CMAKE_BINARY_DIR}/postrm @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/prerm.in ${CMAKE_BINARY_DIR}/prerm @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/upstart/maxscale.conf.in ${CMAKE_BINARY_DIR}/upstart/maxscale.conf @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/test/maxscale_test.cnf ${CMAKE_BINARY_DIR}/maxscale.cnf @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/test/maxscale_test_secondary.cnf ${CMAKE_BINARY_DIR}/maxscale_secondary.cnf @ONLY)
|
||||
@ -256,7 +256,7 @@ if(PACKAGE)
|
||||
install_program(${CMAKE_BINARY_DIR}/maxscale core)
|
||||
install_file(${CMAKE_BINARY_DIR}/maxscale.conf core)
|
||||
install_program(${CMAKE_BINARY_DIR}/postinst core)
|
||||
install_program(${CMAKE_BINARY_DIR}/postrm core)
|
||||
install_program(${CMAKE_BINARY_DIR}/prerm core)
|
||||
|
||||
# The inclusion of CPack needs to be the last effective packaging related command. All
|
||||
# configurations to packaging done after the call will be ignored.
|
||||
|
@ -105,5 +105,5 @@ else()
|
||||
endif()
|
||||
|
||||
message(STATUS "You can install startup scripts and system configuration files for MaxScale by running the 'postinst' shell script located at ${CMAKE_INSTALL_PREFIX}.")
|
||||
message(STATUS "To remove these installed files, run the 'postrm' shell script located in the same folder.")
|
||||
message(STATUS "To remove these installed files, run the 'prerm' shell script located in the same folder.")
|
||||
endif()
|
||||
|
@ -6,7 +6,7 @@ set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
|
||||
if(TARGET_COMPONENT STREQUAL "core" OR TARGET_COMPONENT STREQUAL "all")
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/postinst;${CMAKE_BINARY_DIR}/postrm")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/postinst;${CMAKE_BINARY_DIR}/prerm")
|
||||
elseif(TARGET_COMPONENT STREQUAL "devel")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n${DESCRIPTION_TEXT}")
|
||||
endif()
|
||||
|
@ -39,7 +39,7 @@ set(CPACK_RPM_USER_FILELIST "${IGNORED_DIRS}")
|
||||
|
||||
if(TARGET_COMPONENT STREQUAL "core" OR TARGET_COMPONENT STREQUAL "all")
|
||||
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postinst)
|
||||
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postrm)
|
||||
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/prerm)
|
||||
endif()
|
||||
|
||||
if(EXTRA_PACKAGE_DEPENDENCIES)
|
||||
|
@ -12,8 +12,9 @@ mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
|
||||
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
|
||||
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
|
||||
|
||||
# Create MaxScale user
|
||||
if [ -f "/etc/passwd" ] && [ "$(grep -c 'maxscale' /etc/passwd)" -eq 0 ]
|
||||
# Create MaxScale user if it doesnt' exist
|
||||
getent passwd maxscale > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
groupadd -r maxscale
|
||||
useradd -r -s /bin/false -g maxscale maxscale
|
||||
@ -63,7 +64,9 @@ then
|
||||
fi
|
||||
|
||||
mkdir -p /etc/systemd/system/maxscale.service.d
|
||||
systemctl enable maxscale.service
|
||||
systemctl enable maxscale.service > /dev/null
|
||||
|
||||
systemctl is-active maxscale.service --quiet && systemctl restart maxscale.service
|
||||
else
|
||||
if [ -d "/etc/init/" ] && [ -f "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/upstart/maxscale.conf" ]
|
||||
then
|
||||
@ -77,6 +80,8 @@ else
|
||||
else
|
||||
echo "Could not find init script: @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale" >& 2
|
||||
fi
|
||||
|
||||
service maxscale status > /dev/null && service maxscale restart > /dev/null
|
||||
fi
|
||||
|
||||
# If no maxscale.cnf file is found in /etc, copy the template file there
|
||||
|
@ -19,13 +19,15 @@ then
|
||||
if [ -f /usr/lib/systemd/system/maxscale.service ]
|
||||
then
|
||||
systemctl stop maxscale.service
|
||||
systemctl disable maxscale.service
|
||||
systemctl disable maxscale.service > /dev/null
|
||||
rm /usr/lib/systemd/system/maxscale.service
|
||||
systemctl daemon-reload
|
||||
elif [ -f /lib/systemd/system/maxscale.service ]
|
||||
then
|
||||
systemctl stop maxscale.service
|
||||
systemctl disable maxscale.service
|
||||
systemctl disable maxscale.service > /dev/null
|
||||
rm /lib/systemd/system/maxscale.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
if [ -f /etc/logrotate.d/maxscale_logrotate ]
|
Loading…
x
Reference in New Issue
Block a user