update asterisk16 to 1.6.2.6 and apply fix from #6255; thanks swalker
[packages.git] / net / reaim / files / reaim.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3
4 START=60
5 PATH=/sbin:/bin:/usr/sbin:/usr/bin
6 NAME=reaim
7 DESC="Transparent proxy for IM behind NAT"
8 IPT=/usr/sbin/iptables
9
10 set_rules() {
11         include /lib/network
12         scan_interfaces
13         config_get WAN wan ifname
14
15         [ -z "$WAN" ] && exit
16         $IPT $1 input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT
17         $IPT $1 input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT
18         $IPT $1 input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT
19         $IPT $1 input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT
20 }
21
22 start() {
23         if [ -e /var/run/$NAME.pid ]; then
24                 echo "$DESC: $NAME already started."
25                 exit 0
26         fi
27         echo -n "Starting $DESC: $NAME"
28         
29         set_rules -A
30         test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid
31         /usr/sbin/$NAME
32         echo "."
33 }
34
35 stop() {
36         set_rules -D 2>/dev/null >/dev/null
37         
38         if [ ! -e /var/run/$NAME.pid ]; then
39                 echo "$DESC: $NAME is not running."
40                 exit 0
41         fi
42         echo -n "Stopping $DESC: $NAME"
43
44         killall $NAME
45         rm -f /var/run/$NAME.pid
46
47         echo "."
48 }