mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-07-31 10:09:40 +00:00
036bb24c87
* refactor(packaging): share precise systemd state detection * test(packaging): cover precise systemd state detection * test(packaging): allow explicit Debian init mode * fix(packaging): honor explicit Debian init targets * test(packaging): cover Debian init target detection * fix(packaging): add Debian xcatd init state helper * test(packaging): cover Debian xcatd init state helper * test(packaging): allow delegated SysV registration * fix(packaging): preserve Debian xcatd conffile lifecycle * test(packaging): mirror explicit Debian init mode * test(packaging): cover Debian xcatd conffile lifecycle * fix(packaging): contain init state file umask * test(packaging): cover init state permissions * fix(packaging): contain preinstall context umask * test(packaging): cover preinstall umask containment * fix(packaging): detect all systemd enablement links * test(packaging): cover all systemd enablement links * test(packaging): allow shared purge state path * refactor(packaging): reuse Debian init state path * fix(packaging): detect runtime systemd masks * test(packaging): cover runtime systemd masks * test(packaging): model Debian SysV registration * refactor(packaging): reuse shared init state detection * test(packaging): enforce shared Debian state probes * test(packaging): allow explicit unregistered masks * fix(packaging): preserve Debian SysV registration state * test(packaging): cover Debian SysV registration states * fix(packaging): clean failed Debian state writes * test(packaging): cover failed Debian state writes * fix(packaging): retain unregistered systemd provenance * test(packaging): cover unregistered systemd upgrades * fix(packaging): fail closed on shared state errors * test(packaging): cover shared state detector failures * test(packaging): mirror native xcatd runlevels * fix(packaging): recover rejected SysV layouts * test(packaging): cover rejected SysV layouts * test(packaging): cover SysV rebuild retries * refactor(packaging): reuse systemctl readiness guard * test(packaging): enforce shared systemctl guard
119 lines
3.7 KiB
Bash
119 lines
3.7 KiB
Bash
#!/bin/sh
|
|
# postinst script for openmpi
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
xcatd_init_compat=/opt/xcat/share/xcat/scripts/xcatd-init-compat
|
|
xcatd_init_state=/opt/xcat/share/xcat/scripts/xcatd-init-state
|
|
xcatd_state_dir=/var/lib/xcat/xcatd-init-state
|
|
xcatd_context_file=$xcatd_state_dir/context
|
|
|
|
if [ -L "$xcatd_state_dir" ] || \
|
|
{ [ -e "$xcatd_state_dir" ] && [ ! -d "$xcatd_state_dir" ]; }; then
|
|
echo "Invalid xcatd init state directory: $xcatd_state_dir" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if "$xcatd_init_compat" uses-systemd --explicit-target; then
|
|
xcatd_uses_systemd=yes
|
|
else
|
|
xcatd_uses_systemd=no
|
|
fi
|
|
|
|
if [ -r "$xcatd_context_file" ]; then
|
|
xcatd_transition_context=$(cat "$xcatd_context_file")
|
|
case "$xcatd_transition_context" in
|
|
fresh|upgrade) ;;
|
|
*)
|
|
echo "Invalid xcatd package transition context: $xcatd_transition_context" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
elif [ "$1" = configure ] && [ -n "${2:-}" ]; then
|
|
# Preserve state when invoked for an already configured package even if a
|
|
# prior packaging tool did not provide the explicit preinst context.
|
|
xcatd_transition_context=upgrade
|
|
else
|
|
xcatd_transition_context=fresh
|
|
fi
|
|
|
|
if [ "$xcatd_uses_systemd" = yes ]; then
|
|
if [ "$1" = configure ]; then
|
|
"$xcatd_init_state" prepare-systemd "$xcatd_transition_context"
|
|
fi
|
|
if command -v dpkg-maintscript-helper >/dev/null 2>&1 && \
|
|
dpkg-maintscript-helper supports rm_conffile; then
|
|
dpkg-maintscript-helper rm_conffile /etc/init.d/xcatd -- "$@"
|
|
fi
|
|
fi
|
|
|
|
# summary of how this script can be called:
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
# <new-version>
|
|
# * <postinst> `abort-remove'
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
# <failed-install-package> <version> `removing'
|
|
# <conflicting-package> <version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
|
|
case "$1" in
|
|
configure)
|
|
. /etc/profile.d/xcat.sh
|
|
|
|
if [ "$xcatd_uses_systemd" = yes ]; then
|
|
if command -v update-rc.d >/dev/null 2>&1; then
|
|
update-rc.d -f xcatd remove
|
|
fi
|
|
|
|
"$xcatd_init_compat" configure --explicit-target
|
|
if "$xcatd_init_compat" can-use-systemctl; then
|
|
systemctl daemon-reload
|
|
fi
|
|
desired_enabled=$("$xcatd_init_state" get enabled)
|
|
transition_origin=$("$xcatd_init_state" get origin)
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
case "$transition_origin:$desired_enabled" in
|
|
fresh:yes|legacy:yes) systemctl enable xcatd.service ;;
|
|
legacy:no|legacy:unregistered) systemctl disable xcatd.service ;;
|
|
esac
|
|
fi
|
|
"$xcatd_init_state" commit-systemd
|
|
else
|
|
"$xcatd_init_state" configure-legacy "$xcatd_transition_context"
|
|
fi
|
|
|
|
ln -sf /opt/xcat/sbin/xcatd /usr/sbin/xcatd
|
|
;;
|
|
|
|
abort-upgrade)
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
;;
|
|
|
|
abort-remove|abort-deconfigure)
|
|
;;
|
|
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
# generated by other debhelper scripts.
|
|
|
|
#DEBHELPER#
|
|
|
|
if [ "$1" = configure ]; then
|
|
# Keep explicit context across every fallible postinst step. A retry after
|
|
# this point is a completed configuration and may safely drop it.
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
fi
|
|
|
|
exit 0
|