update README new format of view
[slackbuilds.git] / darkhttpd / rc.darkhttpd
blobb9138abd2b53867e269075a862c7b52056f63d60
1 #!/bin/sh
3 # rc.darkhttpd: Start/Stop the darkhttpd web server
5 # This script assumes you have darkhttpd installed and available in the PATH.
6 # Configuration can be placed in /etc/defaults/darkhttpd
8 # config file /etc/default/darkhttpd:
9 CONFIG_FILE="/etc/default/darkhttpd"
11 # Load options from /etc/default/darkhttpd:
12 # Source the configuration file if it exists
13 if [ -f "$CONFIG_FILE" ]; then
14 . "$CONFIG_FILE"
17 # Function to start darkhttpd
18 start() {
19 if pgrep -x darkhttpd > /dev/null; then
20 echo "darkhttpd is already running."
21 else
22 echo "Starting darkhttpd..."
23 $DARKHTTPD_BIN $DARKHTTPD_ROOT $DARKHTTPD_FLAGS
24 if [ $? -eq 0 ]; then
25 echo "darkhttpd started."
26 else
27 echo "Failed to start darkhttpd."
32 # Function to stop darkhttpd
33 stop() {
34 echo "Stopping darkhttpd..."
35 pkill -x darkhttpd
36 if [ $? -eq 0 ]; then
37 echo "darkhttpd stopped."
38 else
39 echo "Failed to stop darkhttpd or it was not running."
43 # Function to restart darkhttpd
44 restart() {
45 stop
46 sleep 1
47 start
50 # Check for input argument
51 case "$1" in
52 start)
53 start
55 stop)
56 stop
58 restart)
59 restart
62 echo "Usage: $0 {start|stop|restart}"
63 exit 1
65 esac
67 exit 0