procd: convert various packages to procd style init.d scripts
[openwrt/openwrt.git] / package / system / procd / files / log.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2013 OpenWrt.org
3
4 # start after and stop before networking
5 START=21
6 STOP=89
7
8 USE_PROCD=1
9 NAME=logread
10 PROG=/sbin/logread
11
12 start_service_file()
13 {
14 local pid_file="/var/run/logread.${PIDCOUNT}.pid"
15 local log_file log_size
16
17 config_get log_file $1 log_file
18 config_get log_size $1 log_size
19
20 [ -z "${log_file}" ] && return
21
22 procd_open_instance
23 procd_set_param command "$PROG" -f -F "$log_file" -p "$pid_file"
24 [ -n "${log_size}" ] && procd_append_param command -S "$log_size"
25 procd_close_instance
26 }
27
28 start_service_remote()
29 {
30 local pid_file="/var/run/logread.${PIDCOUNT}.pid"
31 local log_ip log_port log_proto
32
33 config_get log_ip $1 log_ip
34 config_get log_port $1 log_port
35 config_get log_proto $1 log_proto udp
36
37 [ -z "${log_ip}" ] && return
38
39 procd_open_instance
40 procd_set_param command "$PROG" -f -r "$log_ip" "${log_port:-514}" -p "$pid_file"
41 [ "${log_proto}" != "udp" ] || procd_append_param command -u
42 procd_close_instance
43 }
44
45 service_triggers()
46 {
47 procd_add_config_trigger "system" "/etc/init.d/log" "start"
48 }
49
50 start_service()
51 {
52 config_load system
53 config_foreach start_service_file system
54 config_foreach start_service_remote system
55 }