69 lines
1.3 KiB
Bash
69 lines
1.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# rc.darkhttpd: Start/Stop the darkhttpd web server
|
|
#
|
|
# This script assumes you have darkhttpd installed and available in the PATH.
|
|
# Configuration can be placed in /etc/defaults/darkhttpd
|
|
|
|
# config file /etc/default/darkhttpd:
|
|
CONFIG_FILE="/etc/default/darkhttpd"
|
|
|
|
# Load options from /etc/default/darkhttpd:
|
|
# Source the configuration file if it exists
|
|
if [ -f "$CONFIG_FILE" ]; then
|
|
. "$CONFIG_FILE"
|
|
fi
|
|
|
|
# Function to start darkhttpd
|
|
start() {
|
|
if pgrep -x darkhttpd > /dev/null; then
|
|
echo "darkhttpd is already running."
|
|
else
|
|
echo "Starting darkhttpd..."
|
|
$DARKHTTPD_BIN $DARKHTTPD_ROOT $DARKHTTPD_FLAGS
|
|
if [ $? -eq 0 ]; then
|
|
echo "darkhttpd started."
|
|
else
|
|
echo "Failed to start darkhttpd."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Function to stop darkhttpd
|
|
stop() {
|
|
echo "Stopping darkhttpd..."
|
|
pkill -x darkhttpd
|
|
if [ $? -eq 0 ]; then
|
|
echo "darkhttpd stopped."
|
|
else
|
|
echo "Failed to stop darkhttpd or it was not running."
|
|
fi
|
|
}
|
|
|
|
# Function to restart darkhttpd
|
|
restart() {
|
|
stop
|
|
sleep 1
|
|
start
|
|
}
|
|
|
|
# Check for input argument
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
|