mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-20 01:12:18 +00:00
fix(debian): retain management configuration context until success
This commit is contained in:
+23
-2
@@ -20,11 +20,28 @@ set -e
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
if [ -L "$state_dir" ] || [ -L "$state_dir/context" ] ||
|
||||
{ [ -e "$state_dir" ] && [ ! -d "$state_dir" ]; }; then
|
||||
echo "Invalid xCAT configuration state: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "$state_dir/context" ]; then
|
||||
context=$(cat "$state_dir/context")
|
||||
case "$context" in
|
||||
fresh|upgrade) ;;
|
||||
*) echo "Invalid xCAT configuration context in $state_dir/context: $context" >&2; exit 1 ;;
|
||||
esac
|
||||
elif [ -f /tmp/xCAT_upgrade.tmp ]; then
|
||||
context=upgrade
|
||||
else
|
||||
context=fresh
|
||||
fi
|
||||
# Make dir for the current pid
|
||||
mkdir -p /var/run/xcat
|
||||
cp -f /opt/xcat/share/xcat/scripts/xHRM /install/postscripts/
|
||||
. /etc/profile.d/xcat.sh
|
||||
if [ -f /tmp/xCAT_upgrade.tmp ]
|
||||
if [ "$context" = upgrade ]
|
||||
then
|
||||
if [ -r "/tmp/xcat/installservice.pid" ]; then
|
||||
mv /tmp/xcat/installservice.pid /var/run/xcat/installservice.pid
|
||||
@@ -36,7 +53,6 @@ case "$1" in
|
||||
mv /tmp/xcat/mainservice.pid /var/run/xcat/mainservice.pid
|
||||
fi
|
||||
xcat_run_upgrade xcatconfig -u -V
|
||||
rm /tmp/xCAT_upgrade.tmp
|
||||
else
|
||||
xcatconfig -i
|
||||
fi
|
||||
@@ -75,4 +91,9 @@ esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
if [ "$1" = configure ]; then
|
||||
rm -f "$state_dir/context" /tmp/xCAT_upgrade.tmp
|
||||
rmdir "$state_dir" 2>/dev/null || :
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|purge|abort-install|disappear)
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
if [ -L "$state_dir" ]; then
|
||||
echo "Invalid xCAT configuration state directory: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$state_dir/context" "$state_dir"/context.* /tmp/xCAT_upgrade.tmp
|
||||
rmdir "$state_dir" 2>/dev/null || :
|
||||
;;
|
||||
upgrade|failed-upgrade|abort-upgrade) ;;
|
||||
*) echo "postrm called with unknown argument: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
|
||||
case "$1" in
|
||||
install) context=fresh ;;
|
||||
upgrade) context=upgrade ;;
|
||||
abort-upgrade) context= ;;
|
||||
*) echo "preinst called with unknown argument: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -n "$context" ]; then
|
||||
if [ -L "$state_dir" ] || [ -L "$state_dir/context" ] ||
|
||||
{ [ -e "$state_dir" ] && [ ! -d "$state_dir" ]; }; then
|
||||
echo "Invalid xCAT configuration state directory: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
# dpkg skips prerm when the previous package was only unpacked.
|
||||
if [ "$context" = upgrade ] && [ ! -f /tmp/xCAT_upgrade.tmp ]; then
|
||||
if [ -f "$state_dir/context" ]; then
|
||||
context=$(cat "$state_dir/context")
|
||||
case "$context" in
|
||||
fresh|upgrade) ;;
|
||||
*) echo "Invalid xCAT configuration context in $state_dir/context: $context" >&2; exit 1 ;;
|
||||
esac
|
||||
else
|
||||
context=fresh
|
||||
fi
|
||||
fi
|
||||
mkdir -p -m 700 "$state_dir"
|
||||
chmod 700 "$state_dir"
|
||||
temporary=$(mktemp "$state_dir/context.XXXXXX")
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
trap 'exit 1' HUP INT TERM
|
||||
printf '%s\n' "$context" > "$temporary"
|
||||
mv -f "$temporary" "$state_dir/context"
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user