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
186 lines
4.6 KiB
Bash
186 lines
4.6 KiB
Bash
#!/bin/sh
|
|
# postrm script for openmpi
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
xcatd_state_dir=/var/lib/xcat/xcatd-init-state
|
|
xcatd_context_file=$xcatd_state_dir/context
|
|
|
|
clear_xcatd_pending_state()
|
|
{
|
|
rm -f "$xcatd_state_dir/pending-xcatd" \
|
|
"$xcatd_state_dir/pending-deleted" \
|
|
"$xcatd_state_dir/pending-enabled" \
|
|
"$xcatd_state_dir/pending-xcatd.tmp."*
|
|
}
|
|
|
|
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
|
|
|
|
xcat_systemd_os_release_status()
|
|
{
|
|
[ -r /etc/os-release ] || return 2
|
|
|
|
os_id=
|
|
os_version=
|
|
while IFS='=' read -r key value; do
|
|
value=${value#\"}
|
|
value=${value%\"}
|
|
value=${value#\'}
|
|
value=${value%\'}
|
|
case "$key" in
|
|
ID) os_id=$value ;;
|
|
VERSION_ID) os_version=$value ;;
|
|
esac
|
|
done < /etc/os-release
|
|
|
|
if [ "$os_id" = "debian" ] && [ -z "$os_version" ]; then
|
|
return 0
|
|
fi
|
|
|
|
os_major=${os_version%%.*}
|
|
case "$os_major" in
|
|
''|*[!0-9]*) return 2 ;;
|
|
esac
|
|
|
|
case "$os_id" in
|
|
rhel|centos|rocky|almalinux|ol|scientific)
|
|
[ "$os_major" -ge 7 ] && return 0
|
|
return 1
|
|
;;
|
|
fedora|ubuntu)
|
|
[ "$os_major" -ge 15 ] && return 0
|
|
return 1
|
|
;;
|
|
debian)
|
|
[ "$os_major" -ge 8 ] && return 0
|
|
return 1
|
|
;;
|
|
sles|sled|opensuse|opensuse-leap|opensuse-tumbleweed)
|
|
[ "$os_major" -ge 12 ] && return 0
|
|
return 1
|
|
;;
|
|
*)
|
|
return 2
|
|
;;
|
|
esac
|
|
|
|
}
|
|
|
|
xcat_target_uses_systemd()
|
|
{
|
|
if [ -d /run/systemd/system ]; then
|
|
return 0
|
|
fi
|
|
|
|
if [ -L /sbin/init ]; then
|
|
init_target=$(readlink /sbin/init 2>/dev/null || true)
|
|
case "$init_target" in
|
|
*systemd*) return 0 ;;
|
|
*) return 1 ;;
|
|
esac
|
|
fi
|
|
|
|
if [ -e /sbin/init ]; then
|
|
return 1
|
|
fi
|
|
|
|
if xcat_systemd_os_release_status; then
|
|
return 0
|
|
else
|
|
os_release_status=$?
|
|
if [ "$os_release_status" -eq 1 ]; then
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
if [ -x /usr/lib/systemd/systemd ] || [ -x /lib/systemd/systemd ]; then
|
|
return 0
|
|
fi
|
|
|
|
return 1
|
|
}
|
|
|
|
if xcat_target_uses_systemd && \
|
|
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
|
|
|
|
# summary of how this script can be called:
|
|
# * <postrm> `remove'
|
|
# * <postrm> `purge'
|
|
# * <old-postrm> `upgrade' <new-version>
|
|
# * <new-postrm> `failed-upgrade' <old-version>
|
|
# * <new-postrm> `abort-install'
|
|
# * <new-postrm> `abort-install' <old-version>
|
|
# * <new-postrm> `abort-upgrade' <old-version>
|
|
# * <disappearer's-postrm> `disappear' <overwriter>
|
|
# <overwriter-version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
|
|
case "$1" in
|
|
purge)
|
|
rm -f /etc/init.d/xcatd \
|
|
/etc/init.d/xcatd.ucf-old \
|
|
/etc/init.d/xcatd.ucf-new \
|
|
/etc/init.d/xcatd.ucf-dist \
|
|
/etc/init.d/xcatd.dpkg-bak \
|
|
/etc/init.d/xcatd.dpkg-backup \
|
|
/etc/init.d/xcatd.dpkg-remove \
|
|
/var/lib/xcat/xcatd-systemd-mode
|
|
rm -f "$xcatd_state_dir/state" \
|
|
"$xcatd_state_dir/xcatd" \
|
|
"$xcatd_state_dir/state.tmp."* \
|
|
"$xcatd_state_dir/xcatd.tmp."*
|
|
clear_xcatd_pending_state
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
rmdir "$xcatd_state_dir" 2>/dev/null || true
|
|
if command -v ucf >/dev/null 2>&1; then
|
|
ucf --purge /etc/init.d/xcatd
|
|
fi
|
|
if command -v ucfr >/dev/null 2>&1; then
|
|
ucfr --purge xcat-server /etc/init.d/xcatd
|
|
fi
|
|
;;
|
|
|
|
abort-install)
|
|
clear_xcatd_pending_state
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
rmdir "$xcatd_state_dir" 2>/dev/null || true
|
|
;;
|
|
|
|
abort-upgrade|disappear)
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
;;
|
|
|
|
upgrade|failed-upgrade)
|
|
;;
|
|
|
|
remove)
|
|
rm -f "$xcatd_context_file" "$xcatd_context_file.tmp."*
|
|
rm -f /usr/sbin/xcatd #remove the symbolic
|
|
|
|
rm -f /etc/apache2/conf-enabled/xcat-ws.conf
|
|
;;
|
|
|
|
*)
|
|
echo "postrm called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
# generated by other debhelper scripts.
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|