First Commit
[librecmc/package-feed.git] / net / socat / files / socat.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008-2014 OpenWrt.org
3
4 START=99
5 STOP=99
6
7 USE_PROCD=1
8 PROG=/usr/bin/socat
9 NAME=socat
10
11 validate_section_socat()
12 {
13         uci_validate_section socat socat "${1}" \
14                 'enable:bool:1' \
15                 'SocatOptions:string'
16         return $?
17 }
18
19 socat_instance()
20 {
21         local SocatOptions enable
22
23         validate_section_socat "${1}" || {
24                 echo "validation failed"
25                 return 1
26         }
27
28         [ "${enable}" = "0" ] && return 1
29
30         procd_open_instance
31         procd_set_param command "$PROG"
32         procd_append_param command ${SocatOptions}
33         procd_close_instance
34 }
35
36 start_service () {
37         config_load "${NAME}"
38         config_foreach socat_instance socat
39 }