blob: b9138abd2b53867e269075a862c7b52056f63d60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/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
|