rtty: Update to 6.5.0
[feed/packages.git] / utils / rtty / files / rtty.init
1 #!/bin/sh /etc/rc.common
2
3 USE_PROCD=1
4 START=99
5
6 BIN=/usr/sbin/rtty
7
8 start_rtty() {
9 . /lib/functions/network.sh
10
11 local cfg="$1"
12 local interface ifname id description host port ssl
13
14 uci_validate_section rtty rtty "${1}" \
15 'interface:uci("network", "@interface"):lan' \
16 'id:maxlength(63)' \
17 'description:maxlength(126)' \
18 'host:host' \
19 'port:port' \
20 'ssl:bool:0' \
21 'keepalive:uinteger:5'
22
23 [ $? -ne 0 ] && {
24 echo "validation failed" >&2
25 return 1
26 }
27
28 [ -n "$interface" ] && network_get_device ifname "$interface"
29
30 [ -z "$ifname" -a -z "$id" ] && {
31 echo "You must specify an interface or ID" >&2
32 return 1
33 }
34
35 [ -z "$host" ] && {
36 echo "host required" >&2
37 return 1
38 }
39
40 [ -z "$port" ] && {
41 echo "port required" >&2
42 return 1
43 }
44
45 procd_open_instance
46 procd_set_param command $BIN -h $host -p $port -a -k $keepalive
47 [ -n "$ifname" ] && procd_append_param command -i "$ifname"
48 [ -n "$id" ] && procd_append_param command -I "$id"
49 [ -n "$description" ] && procd_append_param command -d "$description"
50 [ "$ssl" = "1" ] && procd_append_param command -s
51 procd_set_param respawn
52 procd_close_instance
53 }
54
55 start_service() {
56 config_load rtty
57 config_foreach start_rtty rtty
58 }
59