httpd 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006 OpenWrt.org
  3. START=50
  4. HTTPD_BIN="/usr/sbin/httpd"
  5. system_config() {
  6. local cfg="$1"
  7. config_get hostname "$cfg" hostname
  8. }
  9. httpd_config() {
  10. local cfg="$1"
  11. local c_file port realm home args
  12. config_get c_file "$cfg" c_file
  13. [ -n "$c_file" -a -f "$c_file" ] && append args "-c \"$c_file\""
  14. config_get port "$cfg" port
  15. append args "-p ${port:-80}"
  16. config_get home "$cfg" home
  17. home="${home:-/www}"
  18. [ -d "$home" ] || return 1
  19. append args "-h \"$home\""
  20. config_get realm "$cfg" realm
  21. realm="${realm:-$hostname}"
  22. append args "-r \"$realm\""
  23. eval "$HTTPD_BIN $args"
  24. }
  25. start() {
  26. [ -x "$HTTPD_BIN" ] || return 1
  27. unset hostname
  28. config_load system
  29. config_foreach system_config system
  30. hostname="${hostname:-OpenWrt}"
  31. unset args
  32. config_load httpd
  33. [ "$?" != "0" ] && {
  34. uci_set_default httpd <<EOF
  35. config 'httpd'
  36. option 'port' '80'
  37. option 'home' '/www'
  38. EOF
  39. config_load httpd
  40. }
  41. config_foreach httpd_config httpd
  42. }
  43. stop() {
  44. killall httpd
  45. }