2006-10-04 23:05:48 +03:00
|
|
|
#!/bin/sh /etc/rc.common
|
2006-06-27 03:36:13 +03:00
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
2008-02-28 21:56:09 +02:00
|
|
|
|
2007-05-10 13:38:53 +03:00
|
|
|
START=50
|
2008-02-28 21:56:09 +02:00
|
|
|
HTTPD_BIN="/usr/sbin/httpd"
|
|
|
|
|
|
|
|
system_config() {
|
|
|
|
local cfg="$1"
|
|
|
|
|
|
|
|
config_get hostname "$cfg" hostname
|
|
|
|
}
|
|
|
|
|
|
|
|
httpd_config() {
|
|
|
|
local cfg="$1"
|
2008-09-23 18:24:02 +03:00
|
|
|
local c_file port realm home args
|
2008-02-28 21:56:09 +02:00
|
|
|
|
|
|
|
config_get c_file "$cfg" c_file
|
|
|
|
[ -n "$c_file" -a -f "$c_file" ] && append args "-c \"$c_file\""
|
|
|
|
config_get port "$cfg" port
|
|
|
|
append args "-p ${port:-80}"
|
|
|
|
config_get home "$cfg" home
|
|
|
|
home="${home:-/www}"
|
|
|
|
[ -d "$home" ] || return 1
|
|
|
|
append args "-h \"$home\""
|
|
|
|
config_get realm "$cfg" realm
|
|
|
|
realm="${realm:-$hostname}"
|
|
|
|
append args "-r \"$realm\""
|
|
|
|
eval "$HTTPD_BIN $args"
|
|
|
|
}
|
2006-06-27 03:36:13 +03:00
|
|
|
|
2006-10-04 23:05:48 +03:00
|
|
|
start() {
|
2008-02-28 21:56:09 +02:00
|
|
|
[ -x "$HTTPD_BIN" ] || return 1
|
|
|
|
|
|
|
|
unset hostname
|
|
|
|
config_load system
|
|
|
|
config_foreach system_config system
|
|
|
|
hostname="${hostname:-OpenWrt}"
|
|
|
|
|
|
|
|
unset args
|
|
|
|
config_load httpd
|
|
|
|
[ "$?" != "0" ] && {
|
|
|
|
uci_set_default httpd <<EOF
|
|
|
|
config 'httpd'
|
|
|
|
option 'port' '80'
|
|
|
|
option 'home' '/www'
|
|
|
|
EOF
|
|
|
|
config_load httpd
|
|
|
|
}
|
|
|
|
config_foreach httpd_config httpd
|
2006-10-04 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
killall httpd
|
|
|
|
}
|