packages/net/reaim/files/reaim.init
nbd 2295d502f6 port lots of init scripts over to rc.common (more to come)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@4917 3c298f89-4303-0410-b956-a3cf2f4a3e73
2006-10-04 20:57:49 +00:00

48 lines
978 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=reaim
DESC="Transparent proxy for IM behind NAT"
IPT=/usr/sbin/iptables
include /lib/network
scan_interfaces
config_get WAN wan ifname
set_rules() {
[ -z "$WAN" ] && exit
$IPT $1 input_rule -i $WAN -p tcp --dport 1863:1864 -j ACCEPT
$IPT $1 input_rule -i $WAN -p tcp --dport 4443 -j ACCEPT
$IPT $1 input_rule -i $WAN -p tcp --dport 5566 -j ACCEPT
$IPT $1 input_rule -i $WAN -p tcp --dport 40000:40099 -j ACCEPT
}
start() {
if [ -e /var/run/$NAME.pid ]; then
echo "$DESC: $NAME already started."
exit 0
fi
echo -n "Starting $DESC: $NAME"
set_rules -A
test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid
/usr/sbin/$NAME
echo "."
}
stop() {
set_rules -D 2>/dev/null >/dev/null
if [ ! -e /var/run/$NAME.pid ]; then
echo "$DESC: $NAME is not running."
exit 0
fi
echo -n "Stopping $DESC: $NAME"
killall $NAME
rm -f /var/run/$NAME.pid
echo "."
}