Commit d23b4438 authored by nextime's avatar nextime

Add support for non-interactive wsssh-server package installations

- Modified debconf template to include note about non-interactive handling
- Updated preinst script to detect DEBIAN_FRONTEND=noninteractive
- Automatically stops service in non-interactive environments without prompting
- Changed debconf priority from 'high' to 'medium' for better UX
- Added fallback handling for when debconf fails or returns empty values
- Updated README.md with instructions for non-interactive installations
- Ensures compatibility with automated deployment scripts and CI/CD pipelines
- Maintains user control in interactive environments while enabling automation
parent 0401fb37
......@@ -121,7 +121,14 @@ 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.
**Upgrade Note**: When upgrading the wsssh-server package, if the wssshd service is running, you will be prompted for confirmation before the service is stopped for the upgrade. The service will be automatically restarted afterward if it was running, ensuring zero-downtime upgrades.
**Non-Interactive Installation**: For automated deployments or CI/CD pipelines, use:
```bash
export DEBIAN_FRONTEND=noninteractive
sudo dpkg -i dist/wsssh-server*.deb
```
The service will be stopped and restarted automatically without user interaction.
#### wsssh-tools Package (C Implementation)
```bash
......
......@@ -10,7 +10,7 @@ Vcs-Git: https://git.nexlab.net/nexlab/wsssh.git
Package: wsssh-server
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, debconf (>= 0.5) | debconf-2.0
Description: WebSocket SSH Server (wssshd)
A modern SSH tunneling system that provides WebSocket-based SSH/SCP access
to registered client machines. This package contains the server component
......
......@@ -19,10 +19,32 @@ case "$1" in
if [ -x /etc/init.d/wssshd ]; then
if /etc/init.d/wssshd status >/dev/null 2>&1; then
WSSSHD_RUNNING=1
# Check if we're in a non-interactive environment
if [ -n "$DEBIAN_FRONTEND" ] && [ "$DEBIAN_FRONTEND" = "noninteractive" ]; then
echo "Non-interactive environment detected, stopping wssshd service automatically..."
/etc/init.d/wssshd stop || true
sleep 2
else
# Use debconf to ask user for confirmation
. /usr/share/debconf/confmodule
db_input medium wsssh-server/stop-service || true
db_go || true
# Get the user's answer
db_get wsssh-server/stop-service
if [ "$RET" = "true" ] || [ -z "$RET" ]; then
echo "Stopping wssshd service for upgrade..."
/etc/init.d/wssshd stop || true
# Give it a moment to fully stop
sleep 2
else
echo "User declined to stop wssshd service. Upgrade may fail."
echo "You can manually stop the service with: sudo /etc/init.d/wssshd stop"
echo "Then retry the upgrade."
exit 1
fi
fi
fi
fi
;;
......
Template: wsssh-server/stop-service
Type: boolean
Default: true
Description: Stop wssshd service during upgrade?
The wssshd service is currently running. To upgrade the package safely,
the service needs to be stopped temporarily. It will be restarted
automatically after the upgrade is complete.
.
Should the wssshd service be stopped now?
.
This question will be skipped in non-interactive environments, and the
service will be stopped automatically for safe upgrades.
\ 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