Thanks Adam, this looks really tidy - nice work. Two questions:
1) Can we store (IS_DIRECTORY /lib/init) as a variable like
upstart_FOUND to parallel what we do with systemd?
2) Is there a reason that we are creating /var/lib/matahari in the
upstart script rather than in the install? (We no longer do this in the
init/systemd scripts for Fedora.)
There may be good reasons for both of those - in which case, Ack from me :)
cheers,
Zane.
On 03/11/11 17:48, Adam Stokes wrote:
Support services out of the box on Ubuntu installs.
Signed-off-by: Adam Stokes<astokes(a)fedoraproject.org>
---
src/cmake/modules/MatahariMacros.cmake | 8 +++++++
sys/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++-
sys/matahari-broker.upstart.in | 31 ++++++++++++++++++++++++++++
sys/matahari.upstart.in | 31 ++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 1 deletions(-)
create mode 100644 sys/matahari-broker.upstart.in
create mode 100644 sys/matahari.upstart.in
diff --git a/src/cmake/modules/MatahariMacros.cmake
b/src/cmake/modules/MatahariMacros.cmake
index d0b5af4..77a2d15 100644
--- a/src/cmake/modules/MatahariMacros.cmake
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -129,4 +129,12 @@ macro(create_service_scripts BASE)
configure_file(${CMAKE_SOURCE_DIR}/sys/matahari.service.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.service DESTINATION
${systemdunitdir})
endif(systemd_FOUND)
+
+ if(IS_DIRECTORY /lib/init)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sys/matahari.upstart.in
+ ${CMAKE_CURRENT_BINARY_DIR}/matahari-${BASE}.upstart)
+ install(FILES ${CMAKE_SOURCE_DIR}/matahari-${BASE}.upstart
+ DESTINATION ${sysconfdir}/init
+ RENAME matahari-${BASE}.conf)
+ endif(IS_DIRECTORY /lib/init)
endmacro(create_service_scripts)
diff --git a/sys/CMakeLists.txt b/sys/CMakeLists.txt
index babd6e4..01a21a9 100644
--- a/sys/CMakeLists.txt
+++ b/sys/CMakeLists.txt
@@ -45,7 +45,31 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-guest.init
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/matahari-guest-agent.rules
DESTINATION ${sysconfdir}/udev/rules.d
RENAME 99-matahari-guest-agent.rules)
-
+
+if(IS_DIRECTORY /lib/init)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari.sysconf
+ DESTINATION ${sysconfdir}/default RENAME matahari)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.sysconf
+ DESTINATION ${sysconfdir}/default RENAME matahari-broker)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.conf
+ DESTINATION ${sysconfdir})
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy.sysconf
+ DESTINATION ${sysconfdir}/default RENAME matahari-vios-proxy)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-host.init
+ DESTINATION ${initdir} RENAME matahari-vios-proxy-host)
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-guest.init
+ DESTINATION ${initdir} RENAME matahari-vios-proxy-guest)
+
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/matahari-guest-agent.rules
+ DESTINATION ${sysconfdir}/udev/rules.d
+ RENAME 99-matahari-guest-agent.rules)
+endif(IS_DIRECTORY /lib/init)
# Check for systemd
include(FindPkgConfig)
@@ -69,3 +93,12 @@ if(systemd_FOUND)
endif(systemd_FOUND)
+# Check for upstart
+if(IS_DIRECTORY /lib/init)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-broker.upstart.in
+ ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.upstart)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.upstart
+ DESTINATION ${sysconfdir}/init
+ RENAME matahari-broker.conf)
+endif(IS_DIRECTORY /lib/init)
+
diff --git a/sys/matahari-broker.upstart.in b/sys/matahari-broker.upstart.in
new file mode 100644
index 0000000..f3d560f
--- /dev/null
+++ b/sys/matahari-broker.upstart.in
@@ -0,0 +1,31 @@
+# matahari-broker - matahari qpidd broker daemon
+#
+# Matahari Broker is an AMQP broker. It receives, stores, routes and
+# forwards messages using the AMQP protcol.
+
+description "Matahari broker"
+
+start on runlevel [2345]
+stop on runlevel [06]
+
+expect fork
+respawn
+
+pre-start script
+ mkdir -p -m0775 /var/lib/matahari
+ chgrp qpidd /var/lib/matahari
+end script
+
+script
+ if [ -f @sysconfdir@/default/matahari ]; then
+ . @sysconfdir@/default/matahari
+ fi
+ if [ -f @sysconfdir@/default/matahari-broker ]; then
+ . @sysconfdir@/default/matahari-broker
+ fi
+ if [ -f @sysconfdir@/default/matahari-vios-proxy ]; then
+ . @sysconfdir@/default/matahari-vios-proxy
+ fi
+
+ exec start-stop-daemon --start --quiet --chuid qpidd --exec /usr/sbin/matahari-brokerd
-- $QPIDD_OPTIONS
+end script
diff --git a/sys/matahari.upstart.in b/sys/matahari.upstart.in
new file mode 100644
index 0000000..f22df09
--- /dev/null
+++ b/sys/matahari.upstart.in
@@ -0,0 +1,31 @@
+# matahari-@BASE@@BASE_SUB@ daemon using the AMQP protocol.
+#
+# Matahari Broker is an AMQP broker. It receives, stores, routes and
+# forwards messages using the AMQP protcol.
+
+description "Matahari @BASE@@BASE_SUB@ daemon using the AMQP protocol."
+
+start on runlevel [2345]
+stop on runlevel [06]
+
+expect fork
+respawn
+
+script
+ if [ -f @sysconfdir@/default/matahari ]; then
+ . @sysconfdir@/default/matahari
+ fi
+
+ MATAHARI_ARGS="$MATAHARI_@DAEMON_TYPE@_ARGS $@BASE@_@DAEMON_TYPE@_ARGS"
+ if [ -n "$MATAHARI_PORT" ]; then
+ MATAHARI_ARGS="--port $MATAHARI_PORT $MATAHARI_ARGS"
+ fi
+ if [ -n "$MATAHARI_BROKER" ]; then
+ MATAHARI_ARGS="--broker $MATAHARI_BROKER $MATAHARI_ARGS"
+ fi
+
+ export QPID_SSL_CERT_DB
+ export QPID_SSL_CERT_PASSWORD_FILE
+
+ exec matahari-qmf-@BASE@@BASE_SUB@d $MATAHARI_ARGS --daemon
+end script