diff --git a/CMakeLists.txt b/CMakeLists.txt index c61ea96c6..8945e1952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,7 @@ configure_file(${CMAKE_SOURCE_DIR}/server/include/adminusers.h.in ${CMAKE_BINARY configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY_DIR}/server/include/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/upstart/maxscale.conf.in ${CMAKE_BINARY_DIR}/upstart/maxscale.conf @ONLY) configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.cnf ${CMAKE_BINARY_DIR}/maxscale.cnf @ONLY) set(FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -Werror -fPIC" CACHE STRING "Compilation flags") @@ -284,16 +285,20 @@ if(WITH_SCRIPTS) message(STATUS "maxscale.conf will unpack to: /etc/ld.so.conf.d") message(STATUS "startup scripts will unpack to to: /etc/init.d") message(STATUS "systemd service files will unpack to to: /usr/lib/systemd/system") + message(STATUS "upstart files will unpack to: /etc/init/") install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR} ) install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}) install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION ${MAXSCALE_SHAREDIR}) + install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}/upstart/) else() install(PROGRAMS ${CMAKE_BINARY_DIR}/maxscale DESTINATION /etc/init.d) install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION /etc/ld.so.conf.d) install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION /usr/lib/systemd/system) + install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION /etc/init/) message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d") message(STATUS "Installing startup scripts to: /etc/init.d") message(STATUS "Installing systemd service files to: /usr/lib/systemd/system") + message(STATUS "Installing upstart files to: /etc/init/") endif() endif() diff --git a/etc/postinst.in b/etc/postinst.in index ed155b2b1..91c0e09c8 100755 --- a/etc/postinst.in +++ b/etc/postinst.in @@ -50,6 +50,11 @@ then systemctl daemon-reload fi else + if [ -d "/etc/init/" ] + then + cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/upstart/maxscale.conf /etc/init/ + fi + # If systemd is not present, use init.d scripts if [ -f "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale" ] then diff --git a/etc/upstart/maxscale.conf.in b/etc/upstart/maxscale.conf.in new file mode 100644 index 000000000..bbbc89b5f --- /dev/null +++ b/etc/upstart/maxscale.conf.in @@ -0,0 +1,26 @@ +# MaxScale service + +description "MariaDB MaxScale" + +start on stopped rc RUNLEVEL=[2345] +stop on starting rc runlevel [!2345] + +# Respawn the process on abnormal exits +respawn + +# Uncomment this to limit respawns to two every five minutes +# respawn limit 2 5 + +# Unlimited open files +limit nofile unlimited unlimited + +# Make sure /var/run/maxscale exists +pre-start exec /usr/bin/install -d -o maxscale -g maxscale @MAXSCALE_VARDIR@/run/maxscale + +# Change the user to maxscale:maxscale +setuid maxscale +setgid maxscale + +# Start MaxScale +expect fork +exec /usr/bin/maxscale