Files
op-packages/ghttpd/files/ghttpd.init
T

55 lines
1.0 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
START=93
USE_PROCD=1
get_config() {
config_get enabled $1 enabled "1"
config_get port $1 port "80"
}
stop_default_httpd_services() {
[ "$port" = "80" ] || return 0
for service in uhttpd nginx; do
[ -x "/etc/init.d/$service" ] && "/etc/init.d/$service" stop >/dev/null 2>&1
done
}
start_default_httpd_services() {
for service in uhttpd nginx; do
[ -x "/etc/init.d/$service" ] || continue
"/etc/init.d/$service" enabled && "/etc/init.d/$service" restart
done
}
start_service() {
config_load ghttpd
config_foreach get_config ghttpd
[ "$enabled" != 1 ] && return 1
stop_default_httpd_services
procd_open_instance
procd_set_param command /usr/sbin/ghttpd openwrt
if [ -n "$port" ]; then
procd_append_param command --port "$port"
fi
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
stop_service() {
procd_kill "$NAME"
config_load ghttpd
config_foreach get_config ghttpd
start_default_httpd_services
}
service_triggers() {
procd_add_reload_trigger "ghttpd"
}
reload_service() {
restart
}