Commit 79e67da7 authored by nextime's avatar nextime

Fix Debian init scripts and watchdog installation issues

- Fixed wssshd.init and wssshc.init to work on Debian/Ubuntu systems
- Changed function library from Red Hat (/etc/rc.d/init.d/functions) to Debian (/lib/lsb/init-functions)
- Replaced Red Hat echo_success/echo_failure functions with simple echo statements
- Added watchdog script installation to both wsssh-server and wssshtools debian/rules
- wssshd-watchdog now installs to /usr/sbin/wssshd-watchdog
- wssshc-watchdog now installs to /usr/sbin/wssshc-watchdog
- Fixed init script compatibility issues that were causing 'command not found' errors
- Ensured proper service management on Debian-based systems
- Resolved missing watchdog script errors during service startup
parent 14a4a0a3
......@@ -118,6 +118,9 @@ override_dh_auto_install:
# Install init script
install -m 755 ../wssshd.init debian/wsssh-server/etc/init.d/wssshd
# Install watchdog script
install -m 755 debian/wssshd-watchdog debian/wsssh-server/usr/sbin/wssshd-watchdog
# Install configuration files
install -m 644 debian/wssshd.default debian/wsssh-server/etc/default/wssshd
install -m 644 ../wssshd.conf.example debian/wsssh-server/usr/share/wsssh/
......
......@@ -18,8 +18,8 @@
# Description: WebSocket SSH Client registers with wssshd server and handles SSH connections
### END INIT INFO
# Source function library
. /etc/rc.d/init.d/functions
# Source function library (Debian/Ubuntu)
. /lib/lsb/init-functions
# Configuration
NAME="wssshc"
......@@ -102,15 +102,13 @@ is_running() {
# Function to start the daemon
start() {
echo -n $"Starting $NAME: "
echo -n "Starting $NAME: "
# Check if watchdog is already running
if [ -f "$WATCHDOG_PIDFILE" ]; then
local watchdog_pid=$(cat "$WATCHDOG_PIDFILE")
if kill -0 "$watchdog_pid" 2>/dev/null; then
echo -n "already running (watchdog PID: $watchdog_pid)"
echo_success
echo
echo "already running (watchdog PID: $watchdog_pid)"
return 0
else
# Stale watchdog PID file
......@@ -120,9 +118,7 @@ start() {
# Check if START is enabled
if ! check_start_enabled; then
echo -n "disabled in $DEFAULT_FILE"
echo_failure
echo
echo "disabled in $DEFAULT_FILE"
echo "To enable $NAME, set START=Y in $DEFAULT_FILE"
return 1
fi
......@@ -130,9 +126,7 @@ start() {
# Find configuration file
CONFIG_FILE=$(find_config_file)
if [ $? -ne 0 ]; then
echo -n "configuration file not found"
echo_failure
echo
echo "configuration file not found"
echo "Please create a configuration file:"
echo " System-wide: $CONFIG_SYSTEM"
echo " User-specific: $CONFIG_USER"
......@@ -143,17 +137,13 @@ start() {
# Check if daemon executable exists
if [ ! -x "$DAEMON" ]; then
echo -n "daemon executable $DAEMON not found or not executable"
echo_failure
echo
echo "daemon executable $DAEMON not found or not executable"
return 1
fi
# Check if watchdog script exists
if [ ! -x "$WATCHDOG" ]; then
echo -n "watchdog script $WATCHDOG not found or not executable"
echo_failure
echo
echo "watchdog script $WATCHDOG not found or not executable"
return 1
fi
......@@ -172,31 +162,26 @@ start() {
# Check if watchdog is running
if [ -f "$WATCHDOG_PIDFILE" ] && kill -0 "$(cat "$WATCHDOG_PIDFILE")" 2>/dev/null; then
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
echo "Watchdog failed to start properly"
return 1
fi
else
echo_failure
echo
echo "FAILED"
return $retval
fi
}
# Function to stop the daemon
stop() {
echo -n $"Stopping $NAME: "
echo -n "Stopping $NAME: "
# Check if watchdog is running
if [ ! -f "$WATCHDOG_PIDFILE" ]; then
echo -n "not running"
echo_success
echo
echo "not running"
return 0
fi
......@@ -212,12 +197,10 @@ stop() {
# Clean up PID files
rm -f "$PIDFILE" "$WATCHDOG_PIDFILE"
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
return $retval
fi
}
......@@ -257,12 +240,10 @@ status() {
# Function to reload configuration
reload() {
echo -n $"Reloading $NAME configuration: "
echo -n "Reloading $NAME configuration: "
if ! is_running; then
echo -n "not running"
echo_failure
echo
echo "not running"
return 1
fi
......@@ -270,12 +251,10 @@ reload() {
kill -HUP $pid 2>/dev/null
if [ $? -eq 0 ]; then
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
return 1
fi
}
......
......@@ -18,8 +18,8 @@
# Description: WebSocket SSH Daemon handles WebSocket connections from wsssh/wsscp clients
### END INIT INFO
# Source function library
. /etc/rc.d/init.d/functions
# Source function library (Debian/Ubuntu)
. /lib/lsb/init-functions
# Configuration
NAME="wssshd"
......@@ -55,15 +55,13 @@ is_running() {
# Function to start the daemon
start() {
echo -n $"Starting $NAME: "
echo -n "Starting $NAME: "
# Check if watchdog is already running
if [ -f "$WATCHDOG_PIDFILE" ]; then
local watchdog_pid=$(cat "$WATCHDOG_PIDFILE")
if kill -0 "$watchdog_pid" 2>/dev/null; then
echo -n "already running (watchdog PID: $watchdog_pid)"
echo_success
echo
echo "already running (watchdog PID: $watchdog_pid)"
return 0
else
# Stale watchdog PID file
......@@ -73,9 +71,7 @@ start() {
# Check if config file exists
if [ ! -f "$CONFIG" ]; then
echo -n "configuration file $CONFIG not found"
echo_failure
echo
echo "configuration file $CONFIG not found"
echo "Please create $CONFIG with the required settings."
echo "You can use the example configuration as a template:"
echo " cp /usr/share/wsssh/wssshd.conf.example $CONFIG"
......@@ -84,17 +80,13 @@ start() {
# Check if daemon executable exists
if [ ! -x "$DAEMON" ]; then
echo -n "daemon executable $DAEMON not found or not executable"
echo_failure
echo
echo "daemon executable $DAEMON not found or not executable"
return 1
fi
# Check if watchdog script exists
if [ ! -x "$WATCHDOG" ]; then
echo -n "watchdog script $WATCHDOG not found or not executable"
echo_failure
echo
echo "watchdog script $WATCHDOG not found or not executable"
return 1
fi
......@@ -113,31 +105,26 @@ start() {
# Check if watchdog is running
if [ -f "$WATCHDOG_PIDFILE" ] && kill -0 "$(cat "$WATCHDOG_PIDFILE")" 2>/dev/null; then
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
echo "Watchdog failed to start properly"
return 1
fi
else
echo_failure
echo
echo "FAILED"
return $retval
fi
}
# Function to stop the daemon
stop() {
echo -n $"Stopping $NAME: "
echo -n "Stopping $NAME: "
# Check if watchdog is running
if [ ! -f "$WATCHDOG_PIDFILE" ]; then
echo -n "not running"
echo_success
echo
echo "not running"
return 0
fi
......@@ -153,12 +140,10 @@ stop() {
# Clean up PID files
rm -f "$PIDFILE" "$WATCHDOG_PIDFILE"
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
return $retval
fi
}
......@@ -198,12 +183,10 @@ status() {
# Function to reload configuration
reload() {
echo -n $"Reloading $NAME configuration: "
echo -n "Reloading $NAME configuration: "
if ! is_running; then
echo -n "not running"
echo_failure
echo
echo "not running"
return 1
fi
......@@ -211,12 +194,10 @@ reload() {
kill -HUP $pid 2>/dev/null
if [ $? -eq 0 ]; then
echo_success
echo
echo "OK"
return 0
else
echo_failure
echo
echo "FAILED"
return 1
fi
}
......
......@@ -35,6 +35,9 @@ override_dh_auto_install:
# Install wssshc init script
install -m 755 ../wssshc.init debian/wsssh-tools/etc/init.d/wssshc
# Install wssshc watchdog script
install -m 755 debian/wssshc-watchdog debian/wsssh-tools/usr/sbin/wssshc-watchdog
# Install wssshc configuration files
install -m 644 ../wssshc.conf.example debian/wsssh-tools/usr/share/wsssh/
install -m 644 debian/wssshc.default debian/wsssh-tools/etc/default/wssshc
......
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