- Support for loading vios-proxy-guest or vios-proxy-host with our defined configuration items. - Supports sysv and systemd - Uses /var/lib/libvirt for any proxy related devices - Configuration options available to set service directory and port
Signed-off-by: Adam Stokes astokes@fedoraproject.org --- 99-matahari-guest-agent.rules | 2 + CMakeLists.txt | 22 ++++++++ matahari-vios-proxy-guest.init.in | 96 ++++++++++++++++++++++++++++++++++ matahari-vios-proxy-guest.service.in | 12 ++++ matahari-vios-proxy-host.init.in | 96 ++++++++++++++++++++++++++++++++++ matahari-vios-proxy-host.service.in | 21 +++++++ matahari-vios-proxy.sysconf.in | 7 +++ matahari.spec.in | 71 +++++++++++++++++++++++++ 8 files changed, 327 insertions(+), 0 deletions(-) create mode 100644 99-matahari-guest-agent.rules 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 create mode 100644 matahari-vios-proxy.sysconf.in
diff --git a/99-matahari-guest-agent.rules b/99-matahari-guest-agent.rules new file mode 100644 index 0000000..8cfacee --- /dev/null +++ b/99-matahari-guest-agent.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="virtio-ports", ATTR{name}}=="org.matahariproject.vios_proxy.0", \ + TAG+="systemd" ENV{SYSTEMD_WANTS}="matahari-vios-proxy-guest.service" diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a0be9..1978d82 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) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/matahari-vios-proxy.sysconf.in + ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy.sysconf @ONLY) + install(DIRECTORY DESTINATION ${localstatedir}/lib/matahari DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE) + + install(CODE "execute_process(COMMAND chown root:qpidd ${localstatedir}/lib/matahari)")
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker DESTINATION ${initdir}) @@ -136,6 +147,8 @@ else(WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-broker.conf DESTINATION ${sysconfdir})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matahari-vios-proxy.sysconf DESTINATION ${sysconfdir}/sysconfig RENAME matahari-vios-proxy) + # Check for systemd include(FindPkgConfig) pkg_check_modules(systemd systemd) @@ -146,7 +159,16 @@ 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}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/99-matahari-guest-agent.rules DESTINATION ${sysconfdir}/udev/rules.d) endif(systemd_FOUND)
endif(WIN32) diff --git a/matahari-vios-proxy-guest.init.in b/matahari-vios-proxy-guest.init.in new file mode 100644 index 0000000..c85f712 --- /dev/null +++ b/matahari-vios-proxy-guest.init.in @@ -0,0 +1,96 @@ +#!/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-vios-proxy ]; then + . @sysconfdir@/sysconfig/matahari +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..b1ec32d --- /dev/null +++ b/matahari-vios-proxy-guest.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Matahari Vios Proxy Guest +BindTo=dev-virtio\x2dports-org.matahariproject.vios_proxy.0.device +After=dev-virtio\x2dports-org.matahariproject.vios_proxy.0.device + +[Service] +EnvironmentFile=@sysconfdir@/sysconfig/matahari-vios-proxy +ExecStart=-/usr/bin/vios-proxy-guest $VP_G_HOST_DIR $VP_G_SERVICE_PORT +Restart=always +RestartSec=0 + +[Install] diff --git a/matahari-vios-proxy-host.init.in b/matahari-vios-proxy-host.init.in new file mode 100644 index 0000000..098b9bd --- /dev/null +++ b/matahari-vios-proxy-host.init.in @@ -0,0 +1,96 @@ +#!/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-vios-proxy ]; then + . @sysconfdir@/sysconfig/matahari +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..aa4a77d --- /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-vios-proxy + +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-vios-proxy.sysconf.in b/matahari-vios-proxy.sysconf.in new file mode 100644 index 0000000..abe83c0 --- /dev/null +++ b/matahari-vios-proxy.sysconf.in @@ -0,0 +1,7 @@ +# VIOS Proxy Host configuration +VP_H_GUEST_DIR=/var/lib/libvirt +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.spec.in b/matahari.spec.in index 4bafef7..b52516e 100644 --- a/matahari.spec.in +++ b/matahari.spec.in @@ -104,6 +104,26 @@ 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: %{name}-broker = %{version}-%{release} +Requires: vios-proxy-guest + +%description vios-proxy-guest +%{name} specific guest initialization scripts + %package lib License: GPLv2+ Summary: C libraries used by Matahari agents @@ -213,6 +233,8 @@ rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-host rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-sysconfig rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-sysconfig-console rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-broker +rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-vios-proxy-host +rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-vios-proxy-guest %endif
%post -n matahari-lib -p /sbin/ldconfig @@ -329,6 +351,26 @@ 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 + #== Core
%pre core @@ -511,6 +553,35 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot} %exclude %{_sysconfdir}/matahari-broker.conf %endif
+%files vios-proxy-host +%defattr(644, root, root, 755) +%config(noreplace) %{_sysconfdir}/sysconfig/matahari-vios-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) +%{_sysconfdir}/udev/rules.d/99-matahari-guest-agent.rules +%config(noreplace) %{_sysconfdir}/sysconfig/matahari-vios-proxy + +%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