[packages/xe-guest-utilities] - init scripts, adapterized
adamg
adamg at pld-linux.org
Mon Feb 20 09:17:52 CET 2023
commit cb434199191d81784c0c93d7bbdef00bb34845c4
Author: Adam Gołębiowski <adamg at pld-linux.org>
Date: Mon Feb 20 08:59:27 2023 +0100
- init scripts, adapterized
xe-guest-utilities.init | 95 ++++++++++++++++++++++++++++++++++++++++++++
xe-guest-utilities.spec | 50 ++++++++++++++++-------
xe-guest-utilities.sysconfig | 1 +
3 files changed, 132 insertions(+), 14 deletions(-)
---
diff --git a/xe-guest-utilities.spec b/xe-guest-utilities.spec
index c78fba4..90cc122 100644
--- a/xe-guest-utilities.spec
+++ b/xe-guest-utilities.spec
@@ -5,6 +5,8 @@ Release: 0.0.1
License: BSD
Source0: https://github.com/xenserver/xe-guest-utilities/archive/refs/heads/master/%{name}-%{version}-git.tar.gz
# Source0-md5: 77e4b209aac1243ac806920710c5916c
+Source1: %{name}.init
+Source2: %{name}.sysconfig
URL: https://github.com/xenserver/xe-guest-utilities/
BuildRequires: golang
BuildRequires: rpmbuild(macros) >= 2.009
@@ -14,9 +16,9 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define _debugsource_packages 0
%description
-xe-daemon for monitoring Virtual Machines on a Xen Hypervisor.
-Writes distribution version information, disk and networking
-statistics to XenStore.
+xe-daemon for monitoring Virtual Machines on a Xen Hypervisor. Writes
+distribution version information, disk and networking statistics to
+XenStore.
%prep
%setup -q -n %{name}-master
@@ -28,28 +30,48 @@ ln -sf %{_libdir}/golang/src/cmd/vendor/golang.org vendor
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{_sbindir}
-mv -v build/stage%{_sbindir}/* $RPM_BUILD_ROOT%{_sbindir}
-install -d $RPM_BUILD_ROOT%{_libexecdir}/%{name}
-mv -v build/stage%{_bindir}/* $RPM_BUILD_ROOT%{_libexecdir}/%{name}
+install -d $RPM_BUILD_ROOT{%{_sbindir},%{_libexecdir}/%{name}} \
+ $RPM_BUILD_ROOT/etc/{sysconfig,rc.d/init.d} \
+ $RPM_BUILD_ROOT{%{systemdunitdir},%{_udevrulesdir}} \
+ $RPM_BUILD_ROOT%{_localstatedir}/cache
-install -d $RPM_BUILD_ROOT%{systemdunitdir}
-cp -p mk/xe-linux-distribution.service $RPM_BUILD_ROOT%{systemdunitdir}
-install -d $RPM_BUILD_ROOT%{_udevrulesdir}
-cp -p mk/xen-vcpu-hotplug.rules $RPM_BUILD_ROOT%{_udevrulesdir}/z10-xen-vcpu-hotplug.rules
+install -p build/stage%{_sbindir}/* $RPM_BUILD_ROOT%{_sbindir}
+install -p build/stage%{_bindir}/* $RPM_BUILD_ROOT%{_libexecdir}/%{name}
+install -p mk/xe-linux-distribution.service $RPM_BUILD_ROOT%{systemdunitdir}
+install -p mk/xen-vcpu-hotplug.rules $RPM_BUILD_ROOT%{_udevrulesdir}/z10-xen-vcpu-hotplug.rules
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
-install -d $RPM_BUILD_ROOT%{_localstatedir}/cache
touch $RPM_BUILD_ROOT%{_localstatedir}/cache/xe-linux-distribution
+%post
+/sbin/chkconfig --add xe-guest-utilities
+%service xe-guest-utilities restart "xe-guest-utilities"
+%systemd_reload
+
+%preun
+if [ "$1" = "0" ]; then
+ %service xe-guest-utilitites stop
+ /sbin/chkconfig --del xe-guest-utilitites
+fi
+%systemd_preun xe-guest-utilitites.service
+
+%postun
+%systemd_reload
+
+
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc README.md LICENSE
+%doc CODEOWNERS LICENSE README.md
%attr(755,root,root) %{_sbindir}/xe-daemon
%attr(755,root,root) %{_sbindir}/xe-linux-distribution
+%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/xe-guest-utilities
%{systemdunitdir}/xe-linux-distribution.service
%{_udevrulesdir}/z10-xen-vcpu-hotplug.rules
%{_libexecdir}/xe-guest-utilities
-#%%ghost /var/cache/xe-linux-distribution
+%attr(754,root,root) /etc/rc.d/init.d/xe-guest-utilities
+%ghost /var/cache/xe-linux-distribution
diff --git a/xe-guest-utilities.init b/xe-guest-utilities.init
new file mode 100755
index 0000000..9666777
--- /dev/null
+++ b/xe-guest-utilities.init
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+# xe-guest-utilities write information to XenStore.
+#
+# chkconfig: 345 12 88
+#
+# description: writes system information XenStore.
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/xe-guest-utilities ] && . /etc/sysconfig/xe-guest-utilities
+
+pidfile="/var/run/xe-guest-utilities.pid"
+XE_LINUX_DISTRIBUTION=/usr/sbin/xe-linux-distribution
+XE_LINUX_DISTRIBUTION_CACHE=/var/cache/xe-linux-distribution
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/xe-guest-utilities ]; then
+ msg_already_running "xe-guest-utilities"
+ return
+ fi
+
+ # make sure xenfs is mounted
+ if [ ! -e /proc/xen/xenbus ] ; then
+ if [ ! -d /proc/xen ] ; then
+ fail
+ show "Could not find /proc/xen directory."
+ show "You need a post 2.6.29-rc1 kernel with CONFIG_XEN_COMPAT_XENFS=y and CONFIG_XENFS=y|m"
+ else
+ mount -t xenfs none /proc/xen
+ fi
+ fi
+
+ msg_starting "xe-guest-utilities"
+ ${XE_LINUX_DISTRIBUTION} ${XE_LINUX_DISTRIBUTION_CACHE}
+ daemon --fork /usr/sbin/xe-daemon -p ${pidfile} ${XE_GUEST_UTILITIES_OPTIONS}
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xe-guest-utilities
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/xe-guest-utilities ]; then
+ msg_not_running "xe-guest-utilities"
+ return
+ fi
+
+ # Stop daemons.
+ msg_stopping "xe-guest-utilities"
+ killproc --pidfile $pidfile xe-guest-utilities -TERM
+ rm -f /var/lock/subsys/xe-guest-utilities
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/xe-guest-utilities ]; then
+ msg_not_running "xe-guest-utilities"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ status --pidfile $pidfile xe-guest-utilities
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
diff --git a/xe-guest-utilities.sysconfig b/xe-guest-utilities.sysconfig
new file mode 100644
index 0000000..c14d45a
--- /dev/null
+++ b/xe-guest-utilities.sysconfig
@@ -0,0 +1 @@
+XE_GUEST_UTILITIES_OPTIONS="-i 60"
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/xe-guest-utilities.git/commitdiff/263ed683afd64a14f808ff22199ab74c538f8484
More information about the pld-cvs-commit
mailing list