mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-08-04 16:36:58 +00:00
refactor(packaging): share systemctl readiness guard
(cherry picked from commit ef6e037366)
This commit is contained in:
committed by
github-actions[bot]
parent
f644b39581
commit
12755bcac0
@@ -123,6 +123,11 @@ uses_systemd()
|
||||
return 1
|
||||
}
|
||||
|
||||
can_use_systemctl()
|
||||
{
|
||||
[ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1
|
||||
}
|
||||
|
||||
legacy_state()
|
||||
{
|
||||
for legacy_link in \
|
||||
@@ -395,6 +400,15 @@ case "${1:-}" in
|
||||
esac
|
||||
uses_systemd "$detection_mode"
|
||||
;;
|
||||
can-use-systemctl)
|
||||
case "${2:-}" in
|
||||
'') can_use_systemctl ;;
|
||||
*)
|
||||
echo "Usage: $0 can-use-systemctl" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
legacy-state)
|
||||
legacy_state
|
||||
;;
|
||||
@@ -441,7 +455,7 @@ case "${1:-}" in
|
||||
remove_managed_legacy_init
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {uses-systemd [--explicit-target]|legacy-state|legacy-transition-state|systemd-state|register-legacy {default|enabled|disabled}|unregister-legacy|disable-systemd [--links-only]|unregister-all|configure [--replace] [--explicit-target] [--track-managed]|remove|remove-managed}" >&2
|
||||
echo "Usage: $0 {uses-systemd [--explicit-target]|can-use-systemctl|legacy-state|legacy-transition-state|systemd-state|register-legacy {default|enabled|disabled}|unregister-legacy|disable-systemd [--links-only]|unregister-all|configure [--replace] [--explicit-target] [--track-managed]|remove|remove-managed}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -499,18 +499,13 @@ ln -sf $RPM_INSTALL_PREFIX0/share/xcat/netboot/sles $RPM_INSTALL_PREFIX0/share/x
|
||||
|
||||
ln -sf $RPM_INSTALL_PREFIX0/share/xcat/install/centos $RPM_INSTALL_PREFIX0/share/xcat/install/centos-stream
|
||||
ln -sf $RPM_INSTALL_PREFIX0/share/xcat/netboot/centos $RPM_INSTALL_PREFIX0/share/xcat/netboot/centos-stream
|
||||
xcat_can_use_systemctl()
|
||||
{
|
||||
[ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xcatd_init_compat=$RPM_INSTALL_PREFIX0/share/xcat/scripts/xcatd-init-compat
|
||||
export XCATROOT="$RPM_INSTALL_PREFIX0"
|
||||
|
||||
if [ "$1" = "1" ]; then #Only if installing for the first time..
|
||||
if "$xcatd_init_compat" uses-systemd --explicit-target; then
|
||||
"$xcatd_init_compat" configure --explicit-target || exit 1
|
||||
if xcat_can_use_systemctl; then
|
||||
if "$xcatd_init_compat" can-use-systemctl; then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
@@ -546,7 +541,7 @@ if [ "$1" -gt "1" ]; then #only on upgrade...
|
||||
# packages own /etc/init.d, so leave that directory intact there.
|
||||
rmdir /etc/init.d 2>/dev/null || true
|
||||
%endif
|
||||
if xcat_can_use_systemctl; then
|
||||
if "$xcatd_init_compat" can-use-systemctl; then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
if [ "$legacy_xcatd_state" = enabled ] && command -v systemctl >/dev/null 2>&1; then
|
||||
@@ -631,17 +626,12 @@ fi
|
||||
|
||||
%preun
|
||||
%ifos linux
|
||||
xcat_can_use_systemctl()
|
||||
{
|
||||
[ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xcatd_init_compat=$RPM_INSTALL_PREFIX0/share/xcat/scripts/xcatd-init-compat
|
||||
export XCATROOT="$RPM_INSTALL_PREFIX0"
|
||||
|
||||
if [ $1 == 0 ]; then #This means only on -e
|
||||
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
|
||||
if xcat_can_use_systemctl; then
|
||||
if "$xcatd_init_compat" can-use-systemctl; then
|
||||
systemctl stop xcatd.service
|
||||
elif ! "$xcatd_init_compat" uses-systemd --explicit-target && [ -x /etc/init.d/xcatd ]; then
|
||||
/etc/init.d/xcatd stop
|
||||
|
||||
Reference in New Issue
Block a user