source: trunk/openwrt/package/reaim/files/reaim.init @ 2072

Last change on this file since 2072 was 2072, checked in by nico, 11 years ago

add reaim (thanks to Florian Fainelli)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1#! /bin/sh
2
3PATH=/sbin:/bin:/usr/sbin:/usr/bin
4NAME=reaim
5DESC="Transparent proxy for IM behind NAT"
6. /etc/functions.sh
7WAN=$(nvram get wan_ifname)
8IPT=/usr/sbin/iptables
9case "$1" in
10  start)
11        if [ -e /var/run/$NAME.pid ]; then
12                echo "$DESC: $NAME already started."
13                exit 0
14        fi
15        echo -n "Starting $DESC: $NAME"
16        $IPT -A input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT
17        $IPT -A input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT
18        $IPT -A input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT
19        $IPT -A input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT
20
21        test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid
22        /usr/sbin/$NAME
23        echo "."
24        ;;
25
26  stop)
27        if [ ! -e /var/run/$NAME.pid ]; then
28                echo "$DESC: $NAME is not running."
29                exit 0
30        fi
31        echo -n "Stopping $DESC: $NAME"
32        killall $NAME
33        rm -f /var/run/$NAME.pid
34
35        echo "."
36        ;;
37
38  restart|force-reload)
39        if [ ! -e /var/run/$NAME.pid ]; then
40                $0 start
41                exit 0
42        fi
43        echo -n "Restarting $DESC: $NAME"
44        $IPT -A input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT
45        $IPT -A input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT
46        $IPT -A input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT
47        $IPT -A input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT
48        killall $NAME
49        sleep 1
50        /usr/sbin/$NAME
51        echo "."
52        ;;
53
54  *)
55        N=/etc/init.d/$NAME
56        echo "Usage: $N {start|stop|restart|force-reload}" >&2
57        exit 1
58        ;;
59
60esac
61
62exit 0
Note: See TracBrowser for help on using the repository browser.