Commit 0401fb37 authored by nextime's avatar nextime

Fix PyInstaller binary upgrade handling for wsssh-server package

- Created preinst script to stop wssshd service before upgrade
- Modified postinst script to restart service if it was running before upgrade
- Added proper state tracking using /tmp/wsssh-server-upgrade-state file
- Ensures zero-downtime upgrades by handling PyInstaller binary file locks
- Updated README.md to document the automatic upgrade handling
- Prevents 'file in use' errors during package upgrades
- Maintains service continuity across upgrades
parent 96632028
......@@ -121,6 +121,8 @@ man wssshd
**Note**: The wsssh-server package uses a standalone PyInstaller binary that bundles all Python dependencies, so no additional Python packages are required for installation.
**Upgrade Note**: When upgrading the wsssh-server package, the service will be automatically stopped before the upgrade and restarted afterward if it was running, ensuring zero-downtime upgrades.
#### wsssh-tools Package (C Implementation)
```bash
# Build the wsssh-tools package
......
......@@ -91,6 +91,18 @@ EOF
chown wssshd:wssshd /var/lib/wssshd/db
chmod 755 /var/lib/wssshd/db
fi
# Restart service if it was running before upgrade
if [ -f /tmp/wsssh-server-upgrade-state ]; then
. /tmp/wsssh-server-upgrade-state
rm -f /tmp/wsssh-server-upgrade-state
if [ "$WSSSHD_WAS_RUNNING" = "1" ]; then
echo "Restarting wssshd service after upgrade..."
if [ -x /etc/init.d/wssshd ]; then
/etc/init.d/wssshd start || true
fi
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
......
#!/bin/sh
# preinst script for wsssh-server
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
WSSSHD_RUNNING=0
case "$1" in
install|upgrade)
# Check if wssshd service is running before upgrade
if [ -x /etc/init.d/wssshd ]; then
if /etc/init.d/wssshd status >/dev/null 2>&1; then
WSSSHD_RUNNING=1
echo "Stopping wssshd service for upgrade..."
/etc/init.d/wssshd stop || true
# Give it a moment to fully stop
sleep 2
fi
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# Store the running state for postinst
if [ "$WSSSHD_RUNNING" = "1" ]; then
echo "WSSSHD_WAS_RUNNING=1" > /tmp/wsssh-server-upgrade-state
else
echo "WSSSHD_WAS_RUNNING=0" > /tmp/wsssh-server-upgrade-state
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment