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