Skip to content

Commit

Permalink
Merge pull request #154 from LunfanZhang/private/luzhan/CA-381643
Browse files Browse the repository at this point in the history
CA-381643 Replace systemV Services control with systemd
  • Loading branch information
LunfanZhang authored Aug 29, 2023
2 parents 4be6540 + 694ff10 commit 3b09e81
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions mk/xe-guest-utilities.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mkdir -p %{buildroot}/usr/sbin/
mkdir -p %{buildroot}/usr/share/doc/%{name}-%{version}/examples/
mkdir -p %{buildroot}/etc/init.d
mkdir -p %{buildroot}/etc/udev/rules.d
mkdir -p %{buildroot}/usr/lib/systemd/system

cp %{SOURCE0} %{buildroot}/usr/sbin/xe-linux-distribution
chmod 755 %{buildroot}/usr/sbin/xe-linux-distribution
Expand All @@ -51,6 +52,9 @@ chmod 755 %{buildroot}/etc/init.d/xe-linux-distribution
cp %{SOURCE3} %{buildroot}/usr/sbin/xe-daemon
chmod 755 %{buildroot}/usr/sbin/xe-daemon

cp mk/xe-linux-distribution.service %{buildroot}/usr/lib/systemd/system/xe-linux-distribution.service
chmod 644 %{buildroot}/usr/lib/systemd/system/xe-linux-distribution.service

cp %{SOURCE5} %{buildroot}/usr/share/doc/%{name}-%{version}/examples/

install -d %{buildroot}/usr/bin/
Expand All @@ -75,8 +79,16 @@ cp %{SOURCE8} %{buildroot}/usr/share/doc/%{name}-xenstore-%{version}/
rm -rf %{buildroot}

%post
/sbin/chkconfig --add xe-linux-distribution >/dev/null
[ -n "${EXTERNAL_P2V}" ] || service xe-linux-distribution start >/dev/null 2>&1
#!/bin/bash
if command -v systemctl >/dev/null 2>&1; then
xe_install_path=/usr/sbin
sed -i "s#/usr/share/oem/xs#$xe_install_path#g" /usr/lib/systemd/system/xe-linux-distribution.service
systemctl enable /usr/lib/systemd/system/xe-linux-distribution.service >/dev/null 2>&1
systemctl start xe-linux-distribution.service >/dev/null 2>&1
else
/sbin/chkconfig --add xe-linux-distribution >/dev/null
[ -n "${EXTERNAL_P2V}" ] || service xe-linux-distribution start >/dev/null 2>&1
fi

eval $(/usr/sbin/xe-linux-distribution)

Expand All @@ -94,8 +106,13 @@ fi

%preun
if [ $1 -eq 0 ] ; then
service xe-linux-distribution stop >/dev/null 2>&1
/sbin/chkconfig --del xe-linux-distribution >/dev/null
if command -v systemctl >/dev/null 2>&1; then
systemctl stop xe-linux-distribution.service >/dev/null 2>&1
systemctl disable xe-linux-distribution.service >/dev/null 2>&1
else
service xe-linux-distribution stop >/dev/null 2>&1
/sbin/chkconfig --del xe-linux-distribution >/dev/null
fi
fi

%files
Expand All @@ -105,6 +122,7 @@ fi
/usr/sbin/xe-daemon
/etc/udev/rules.d/z10-xen-vcpu-hotplug.rules
/usr/share/doc/%{name}-%{version}/LICENSE
/usr/lib/systemd/system/xe-linux-distribution.service

%files xenstore
%defattr(-,root,root,-)
Expand Down

0 comments on commit 3b09e81

Please sign in to comment.