A couple of minor comments inline. No major issues from me.
I think I'd prefer to see the configuration go in a separate /etc/sysconfig/ file, since there is no actual information shared between the host and the proxy.
Unless you want to change the broker to automatically federate with the proxy if it exists. That would be cool.
cheers, Zane.
On 10/10/11 17:24, Adam Stokes wrote:
- Support for loading vios-proxy-guest or vios-proxy-host with our defined configuration items.
- Supports sysv and systemd
- Creates a proxy directory under /var/lib/matahari to keep all guest devices seperate
- Configuration options available to set service directory and port
Signed-off-by: Adam Stokesastokes@fedoraproject.org
CMakeLists.txt | 19 +++++++ matahari-broker.sysconf.in | 7 +++ matahari-vios-proxy-guest.init.in | 99 ++++++++++++++++++++++++++++++++++ matahari-vios-proxy-guest.service.in | 21 +++++++ matahari-vios-proxy-host.init.in | 99 ++++++++++++++++++++++++++++++++++ matahari-vios-proxy-host.service.in | 21 +++++++ matahari.spec.in | 86 +++++++++++++++++++++++++++++ 7 files changed, 352 insertions(+), 0 deletions(-) create mode 100644 matahari-vios-proxy-guest.init.in create mode 100644 matahari-vios-proxy-guest.service.in create mode 100644 matahari-vios-proxy-host.init.in create mode 100644 matahari-vios-proxy-host.service.in
diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a0be9..dc85c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,9 +123,20 @@ else(WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-broker.sysconf.in ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.sysconf @ONLY)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-vios-proxy-host.init.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-host.init @ONLY)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-vios-proxy-guest.init.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-guest.init @ONLY)
- install(DIRECTORY DESTINATION ${localstatedir}/lib/matahari DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE)
- install(DIRECTORY DESTINATION ${localstatedir}/lib/matahari/proxy
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE)
What owner and group does this end up with? The /var/lib/matahari has a particularly weird set of permissions; there's probably no need to copy them and every reason to go with something more standard.
install(CODE "execute_process(COMMAND chown root:qpidd ${localstatedir}/lib/matahari)") install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker DESTINATION ${initdir})
@@ -146,7 +157,15 @@ else(WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-broker.service.in ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.service)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-vios-proxy-host.service.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-host.service)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-vios-proxy-guest.service.in
${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-guest.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.service DESTINATION ${systemdunitdir})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-host.service DESTINATION ${systemdunitdir})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy-guest.service DESTINATION ${systemdunitdir}) endif(systemd_FOUND)
endif(WIN32)
diff --git a/matahari-broker.sysconf.in b/matahari-broker.sysconf.in index 4d3cf12..522da7f 100644 --- a/matahari-broker.sysconf.in +++ b/matahari-broker.sysconf.in @@ -16,3 +16,10 @@ QPIDD_OPTIONS="--config @sysconfdir@/matahari-broker.conf" # Addresses need not all be in the same format. #FEDERATED_BROKERS="broker1.example.com:49000, _matahari._tcp.example.com"
+# VIOS Proxy Host configuration +VP_H_GUEST_DIR=/var/lib/matahari/proxy +VP_H_SERVICE_PORT=49000 +# +# VIOS Proxy Guest configuration +VP_G_HOST_DIR=/dev/virtio-ports +VP_G_SERVICE_PORT=48999 diff --git a/matahari-vios-proxy-guest.init.in b/matahari-vios-proxy-guest.init.in new file mode 100644 index 0000000..e3c0e71 --- /dev/null +++ b/matahari-vios-proxy-guest.init.in @@ -0,0 +1,99 @@ +#!/bin/sh
+# the following is chkconfig init header +# matahari-vios-proxy-guest: Initscript for Matahari specific vios-proxy +### BEGIN INIT INFO +# Provides: +# Required-Start: $local_fs matahari-broker +# Required-Stop: $local_fs matahari-broker +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts and stops vios proxy guest daemon +# Description: Matahari initscript for Vios Proxy Guest +### END INIT INFO
+# chkconfig: - 99 01 +# description: Matahari initscript for Vios Proxy Guest +# processname: matahari-vios-proxy-guest +# pidfile: @localstatedir@/run/matahari-vios-proxy-guest.pid +#
+# Turn off automatic systemd redirects +#SYSTEMCTL_SKIP_REDIRECT=1
+# Source function library. +. @sysconfdir@/rc.d/init.d/functions
+PROCESS=vios-proxy-guest
+RETVAL=0
+# Source function library. +. @sysconfdir@/rc.d/init.d/functions
+if [ -f @sysconfdir@/sysconfig/matahari ]; then
- . @sysconfdir@/sysconfig/matahari
+fi
Is this actually required? It's not in the systemd one
+if [ -f @sysconfdir@/sysconfig/matahari-broker ]; then
- . @sysconfdir@/sysconfig/matahari-broker
+fi
+start() {
- echo -n $"Starting the $PROCESS daemon: "
- daemon $PROCESS $VP_H_GUEST_DIR $VP_H_SERVICE_DIR
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ]&& touch @localstatedir@/lock/subsys/$PROCESS
+}
+stop() {
- echo -n $"Stopping the $PROCESS daemon: "
- killproc $PROCESS
- RETVAL=$?
- echo
- if [ $RETVAL -eq 0 ]; then
rm -f @localstatedir@/lock/subsys/$PROCESS
rm -f @localstatedir@/run/$PROCESS.pid
- fi
+}
+restart() {
- stop
- start
+}
+reload() {
- echo -n $"Reloading the $PROCESS configuration: "
- killproc $PROCESS -HUP
- RETVAL=$?
- echo
- return $RETVAL
+}
+# See how we were called. +case "$1" in
- start)
status $PROCESS>/dev/null || $1
;;
- stop|restart|reload)
$1
;;
- status)
status $PROCESS
RETVAL=$?
;;
- force-reload)
reload
;;
- condrestart|try-restart)
[ -f @localstatedir@/lock/subsys/$PROCESS ]&& restart || :
;;
- *)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
;;
+esac +exit $RETVAL diff --git a/matahari-vios-proxy-guest.service.in b/matahari-vios-proxy-guest.service.in new file mode 100644 index 0000000..89a4ecb --- /dev/null +++ b/matahari-vios-proxy-guest.service.in @@ -0,0 +1,21 @@ +[Unit] +Description=Matahari specific requirements for a Vios proxy guest +After=syslog.target +Requires=syslog.target
+[Install] +WantedBy=multi-user.target
+[Service] +Type=simple +NotifyAccess=all +SysVStartPriority=85 +User=root +Group=root
+EnvironmentFile=-@sysconfdir@/sysconfig/matahari-broker
Maybe lose the - as it will be an error if we don't have these vars defined.
+ExecStart=/usr/bin/vios-proxy-guest $VP_G_HOST_DIR $VP_G_SERVICE_PORT
+# Restart options include: no, on-success, on-failure, on-abort or always +Restart=on-failure diff --git a/matahari-vios-proxy-host.init.in b/matahari-vios-proxy-host.init.in new file mode 100644 index 0000000..e0c81e4 --- /dev/null +++ b/matahari-vios-proxy-host.init.in @@ -0,0 +1,99 @@ +#!/bin/sh
+# the following is chkconfig init header +# matahari-vios-proxy-host: Initscript for Matahari specific vios-proxy +### BEGIN INIT INFO +# Provides: +# Required-Start: $local_fs matahari-broker +# Required-Stop: $local_fs matahari-broker +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts and stops vios proxy host daemon +# Description: Matahari initscript for Vios Proxy Host +### END INIT INFO
+# chkconfig: - 99 01 +# description: Matahari initscript for Vios Proxy Host +# processname: matahari-vios-proxy-host +# pidfile: @localstatedir@/run/matahari-vios-proxy-host.pid +#
+# Turn off automatic systemd redirects +#SYSTEMCTL_SKIP_REDIRECT=1
+# Source function library. +. @sysconfdir@/rc.d/init.d/functions
+PROCESS=vios-proxy-host
+RETVAL=0
+# Source function library. +. @sysconfdir@/rc.d/init.d/functions
+if [ -f @sysconfdir@/sysconfig/matahari ]; then
- . @sysconfdir@/sysconfig/matahari
+fi +if [ -f @sysconfdir@/sysconfig/matahari-broker ]; then
- . @sysconfdir@/sysconfig/matahari-broker
+fi
+start() {
- echo -n $"Starting the $PROCESS daemon: "
- daemon $PROCESS $VP_H_GUEST_DIR $VP_H_SERVICE_DIR
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ]&& touch @localstatedir@/lock/subsys/$PROCESS
+}
+stop() {
- echo -n $"Stopping the $PROCESS daemon: "
- killproc $PROCESS
- RETVAL=$?
- echo
- if [ $RETVAL -eq 0 ]; then
rm -f @localstatedir@/lock/subsys/$PROCESS
rm -f @localstatedir@/run/$PROCESS.pid
- fi
+}
+restart() {
- stop
- start
+}
+reload() {
- echo -n $"Reloading the $PROCESS configuration: "
- killproc $PROCESS -HUP
- RETVAL=$?
- echo
- return $RETVAL
+}
+# See how we were called. +case "$1" in
- start)
status $PROCESS>/dev/null || $1
;;
- stop|restart|reload)
$1
;;
- status)
status $PROCESS
RETVAL=$?
;;
- force-reload)
reload
;;
- condrestart|try-restart)
[ -f @localstatedir@/lock/subsys/$PROCESS ]&& restart || :
;;
- *)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
;;
+esac +exit $RETVAL diff --git a/matahari-vios-proxy-host.service.in b/matahari-vios-proxy-host.service.in new file mode 100644 index 0000000..cc39bc9 --- /dev/null +++ b/matahari-vios-proxy-host.service.in @@ -0,0 +1,21 @@ +[Unit] +Description=Matahari specific requirements for a Vios proxy host +After=syslog.target +Requires=syslog.target
+[Install] +WantedBy=multi-user.target
+[Service] +Type=simple +NotifyAccess=all +SysVStartPriority=85 +User=root +Group=root
+EnvironmentFile=-@sysconfdir@/sysconfig/matahari-broker
+ExecStart=/usr/bin/vios-proxy-host $VP_H_GUEST_DIR $VP_H_SERVICE_PORT
+# Restart options include: no, on-success, on-failure, on-abort or always +Restart=on-failure diff --git a/matahari.spec.in b/matahari.spec.in index 4bafef7..933c0db 100644 --- a/matahari.spec.in +++ b/matahari.spec.in @@ -104,6 +104,25 @@ Requires: qmf> 0.7 Optional AMQP Broker for Matahari %endif
+%package vios-proxy-host +License: ASL 2.0 +Summary: Network proxy using virtioserial for QEMU host +Group: Applications/System +Requires: %{name}-broker = %{version}-%{release} +Requires: vios-proxy-host
+%description vios-proxy-host +%{name} specific host initialization scripts
+%package vios-proxy-guest +License: ASL 2.0 +Summary: Network proxy using virtioserial for QEMU guest +Group: Applications/System +Requires: vios-proxy-guest
+%description vios-proxy-guest +%{name} specific guest initialization scripts
- %package lib License: GPLv2+ Summary: C libraries used by Matahari agents
@@ -329,6 +348,46 @@ if [ "$1" -ge "1" ]; then /sbin/service matahari-broker condrestart>/dev/null 2>&1 || : fi
+#== Vios Proxy Host +%post vios-proxy-host +%if %{systemd} +systemctl --system daemon-reload +%endif +/sbin/service matahari-vios-proxy-host condrestart
+%preun vios-proxy-host +if [ $1 = 0 ]; then
- /sbin/service matahari-vios-proxy-host stop>/dev/null 2>&1 || :
+%if !%{systemd}
- chkconfig --del matahari-vios-proxy-host
+%endif +fi
+%postun vios-proxy-host +if [ "$1" -ge "1" ]; then
- /sbin/service matahari-vios-proxy-host condrestart>/dev/null 2>&1 || :
+fi
+#== Vios Proxy Guest +%post vios-proxy-guest +%if %{systemd} +systemctl --system daemon-reload +%endif +/sbin/service matahari-vios-proxy-guest condrestart
+%preun vios-proxy-guest +if [ $1 = 0 ]; then
- /sbin/service matahari-vios-proxy-guest stop>/dev/null 2>&1 || :
+%if !%{systemd}
- chkconfig --del matahari-vios-proxy-guest
+%endif +fi
+%postun vios-proxy-guest +if [ "$1" -ge "1" ]; then
- /sbin/service matahari-vios-proxy-guest condrestart>/dev/null 2>&1 || :
+fi
#== Core
%pre core
@@ -511,6 +570,33 @@ test "x%{buildroot}" != "x"&& rm -rf %{buildroot} %exclude %{_sysconfdir}/matahari-broker.conf %endif
+%files vios-proxy-host +%defattr(644, root, root, 755) +%dir %attr(0770, root, qpidd) %{_localstatedir}/lib/%{name}/proxy
+%if %{systemd} +%{_unitdir}/matahari-vios-proxy-host.service +%endif
+%if %{with qmf} +%if !%{systemd} +%attr(755, root, root) %{_initddir}/matahari-vios-proxy-host +%endif +%endif
+%files vios-proxy-guest +%defattr(644, root, root, 755)
+%if %{systemd} +%{_unitdir}/matahari-vios-proxy-guest.service +%endif
+%if %{with qmf} +%if !%{systemd} +%attr(755, root, root) %{_initddir}/matahari-vios-proxy-guest +%endif +%endif
- %files devel %defattr(644, root, root, 755) %doc AUTHORS COPYING