* Reworked Theme "Fledermaus"
[project/luci.git] / module / admin-core / contrib / init.d / luci_freifunk
1 #!/bin/sh /etc/rc.common
2 START=70
3
4 start() {
5         include /lib/network
6         scan_interfaces
7         
8         
9         ### Read interface names
10         config_get wanif wan ifname
11         config_get lanif lan ifname
12         config_get ffif  ff  ifname
13         
14         
15         [ -n "$ffif" ] || return 0
16                 
17         
18         ### Read from config
19         config_load freifunk
20         
21         config_get_bool internal routing internal
22         [ -n "$wanif" ] && config_get_bool internet routing internal
23         
24         
25         ### Freifunk to Freifunk
26         [ "$internal" -gt 0 ] && {
27                 iptables -A forwarding_rule -i "$ffif" -o "$ffif" -j ACCEPT
28         }
29         
30         ### Lan to Freifunk     
31         [ -n "$lanif" ] && {
32                 iptables -A forwarding_rule -i "$lanif" -o "$ffif" -j ACCEPT
33                 iptables -t nat -A postrouting_rule -i "$lanif" -o "$ffif" -j MASQUERADE
34         }
35         
36         ### Freifunk to Wan
37         [ "$internet" -gt 0 ] && {
38                 iptables -A forwarding_rule -i "$ffif" -o "$wanif" -j ACCEPT
39                 iptables -t nat -A postrouting_rule -i "$ffif" -o "$wanif" -j MASQUERADE
40         }
41 }
42
43 stop() {
44         include /lib/network
45         scan_interfaces
46         
47         ### Read interface names
48         config_get wanif wan ifname
49         config_get lanif lan ifname
50         config_get ffif  ff  ifname
51         
52         [ -n "$ffif" ] || return 0
53         
54         ### Freifunk to Freifunk
55         iptables -D forwarding_rule -i "$ffif" -o "$ffif" -j ACCEPT
56         
57         ### Lan to Freifunk     
58         [ -n "$lanif" ] && {
59                 iptables -D forwarding_rule -i "$lanif" -o "$ffif" -j ACCEPT
60                 iptables -t nat -D postrouting_rule -i "$lanif" -o "$ffif" -j MASQUERADE
61         }
62         
63         ### Freifunk to Wan
64         [ -n "$wanif" -gt 0 ] && {
65                 iptables -D forwarding_rule -i "$ffif" -o "$wanif" -j ACCEPT
66                 iptables -t nat -D postrouting_rule -i "$ffif" -o "$wanif" -j MASQUERADE
67         }
68 }