diff options
author | Katze Miau <miaukatzemiau@priveasy.de> | 2011-10-16 07:34:24 (GMT) |
---|---|---|
committer | Katze Miau <miaukatzemiau@priveasy.de> | 2011-10-16 07:34:24 (GMT) |
commit | 9ae01954ef11947693894cf188d75603ab161aac (patch) | |
tree | 84a28cd644955e52bd6b91f2c474e9f338841119 /files/common/etc | |
parent | 425e20c0b13cb117e4d2fff04f523478a0618e24 (diff) |
add makefile to generate images
Diffstat (limited to 'files/common/etc')
-rw-r--r-- | files/common/etc/config/batman-adv | 10 | ||||
-rw-r--r-- | files/common/etc/config/firewall | 50 | ||||
-rw-r--r-- | files/common/etc/config/n2n | 17 | ||||
-rw-r--r-- | files/common/etc/config/network | 39 | ||||
-rw-r--r-- | files/common/etc/config/splash_users | 1 | ||||
-rw-r--r-- | files/common/etc/config/system | 17 | ||||
-rw-r--r-- | files/common/etc/config/uhttpd | 39 | ||||
-rw-r--r-- | files/common/etc/config/wireless | 16 | ||||
-rw-r--r-- | files/common/etc/crontabs/root | 1 | ||||
-rw-r--r-- | files/common/etc/dropbear/authorized_keys | 8 | ||||
-rw-r--r-- | files/common/etc/hotplug.d/iface/22-wan_led | 15 | ||||
-rwxr-xr-x | files/common/etc/init.d/batman-adv | 103 | ||||
-rwxr-xr-x | files/common/etc/init.d/dnsmasq | 386 | ||||
-rwxr-xr-x | files/common/etc/init.d/n2n | 43 | ||||
-rw-r--r-- | files/common/etc/rc.local | 4 |
15 files changed, 749 insertions, 0 deletions
diff --git a/files/common/etc/config/batman-adv b/files/common/etc/config/batman-adv new file mode 100644 index 0000000..cc8db5f --- /dev/null +++ b/files/common/etc/config/batman-adv @@ -0,0 +1,10 @@ +config 'mesh' 'bat0' + option 'interfaces' 'ath1' + option 'orig_interval' + option 'log_level' + option 'aggregated_ogms' + option 'bonding' + option 'fragmentation' + option 'vis_mode' + option 'gw_mode' 'client' + diff --git a/files/common/etc/config/firewall b/files/common/etc/config/firewall new file mode 100644 index 0000000..4b702ba --- /dev/null +++ b/files/common/etc/config/firewall @@ -0,0 +1,50 @@ +config defaults + option syn_flood 1 + option input ACCEPT + option output ACCEPT + option forward REJECT + +config zone + option name wan + option input REJECT + option output ACCEPT + option forward REJECT + option masq 1 + option mtu_fix 1 +config zone + option name mesh + option input ACCEPT + option output ACCEPT + option forward REJECT +config zone + option name lan + option input ACCEPT + option output ACCEPT + option forward REJECT +config forwarding + option src mesh + option dest wan + +config forwarding + option src lan + option dest wan + +# We need to accept udp packets on port 68, +# see https://dev.openwrt.org/ticket/4108 +config rule + option src wan + option proto udp + option dest_port 68 + option target ACCEPT + +#Allow ping +config rule + option src wan + option proto icmp + option icmp_type echo-request + option target ACCEPT + +# include a file with users custom iptables rules +config include + option path /etc/firewall.user + diff --git a/files/common/etc/config/n2n b/files/common/etc/config/n2n new file mode 100644 index 0000000..58cccdc --- /dev/null +++ b/files/common/etc/config/n2n @@ -0,0 +1,17 @@ +config edge + option ipaddr '1.2.3.4' + option supernode 'fritz-der-server.de' + option port '2009' + option community 'ffj1' + option key 'ffj1' + option devname 'n2n1' + option route '' +config edge + option ipaddr '1.2.3.4' + option supernode '89.238.83.22' + option port '9876' + option community 'ffj2' + option key 'ffj2' + option devname 'n2n2' + option route '' + diff --git a/files/common/etc/config/network b/files/common/etc/config/network new file mode 100644 index 0000000..b0d6d9e --- /dev/null +++ b/files/common/etc/config/network @@ -0,0 +1,39 @@ + +config 'interface' 'loopback' + option 'ifname' 'lo' + option 'proto' 'static' + option 'ipaddr' '127.0.0.1' + option 'netmask' '255.0.0.0' + +config 'interface' 'mesh' + option 'type' 'bridge' + option 'ifname' 'bat0 ath0' + option 'mtu' '1527' + +config 'interface' 'lan' + option 'type' 'bridge' + option 'proto' 'static' + option 'ipaddr' '10.17.200.1' + option 'netmask' '255.255.255.0' + option 'ifname' 'eth0.1' + +config 'switch' 'eth0' + option 'name' 'eth0' + option 'reset' '1' + option 'enable_vlan' '1' + +config 'switch_vlan' 'eth0_1' + option 'device' 'eth0' + option 'vlan' '1' + option 'ports' '0 1 2 3 5t' + +config 'switch_vlan' 'eth0_2' + option 'device' 'eth0' + option 'vlan' '2' + option 'ports' '4 5t' + +config 'interface' 'wan' + option 'ifname' 'eth0.2' + option 'proto' 'dhcp' + option 'dns' '217.11.48.200 217.11.49.200 8.8.8.8' + diff --git a/files/common/etc/config/splash_users b/files/common/etc/config/splash_users new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/files/common/etc/config/splash_users @@ -0,0 +1 @@ + diff --git a/files/common/etc/config/system b/files/common/etc/config/system new file mode 100644 index 0000000..3d9683c --- /dev/null +++ b/files/common/etc/config/system @@ -0,0 +1,17 @@ +config system + option hostname OpenWrt + option timezone CET + +config button + option button reset + option action released + option handler "logger reboot" + option min 0 + option max 4 + +config button + option button reset + option action released + option handler "logger factory default" + option min 5 + option max 30 diff --git a/files/common/etc/config/uhttpd b/files/common/etc/config/uhttpd new file mode 100644 index 0000000..8320d42 --- /dev/null +++ b/files/common/etc/config/uhttpd @@ -0,0 +1,39 @@ +# Server configuration +config uhttpd main + + # HTTP listen addresses, multiple allowed + list listen_http 0.0.0.0:80 + # Server document root + option home /www + option error_page /cgi-bin/redirect + option index_page cgi-bin/redirect + # Reject requests from RFC1918 IP addresses + # directed to the servers public IP(s). + # This is a DNS rebinding countermeasure. + option rfc1918_filter 1 + + # CGI url prefix, will be searched in docroot. + # Default is /cgi-bin + option cgi_prefix /cgi-bin + + # CGI/Lua timeout, if the called script does not + # write data within the given amount of seconds, + # the server will terminate the request with + # 504 Gateway Timeout response. + option script_timeout 60 + + # Network timeout, if the current connection is + # blocked for the specified amount of seconds, + # the server will terminate the associated + # request process. + option network_timeout 30 + + # TCP Keep-Alive, send periodic keep-alive probes + # over established connections to detect dead peers. + # The value is given in seconds to specify the + # interval between subsequent probes. + # Setting this to 0 will disable TCP keep-alive. + option tcp_keepalive 1 + + + diff --git a/files/common/etc/config/wireless b/files/common/etc/config/wireless new file mode 100644 index 0000000..17dd0b7 --- /dev/null +++ b/files/common/etc/config/wireless @@ -0,0 +1,16 @@ +config wifi-device wifi0 + option type atheros + option channel 1 + +config wifi-iface + option device wifi0 + option mode adhoc + option ssid batman.jena.freifunk.net + option bssid 12:CA:FF:EE:BA:BE + option hidden 1 + +config wifi-iface + option device wifi0 + option mode ap + option ssid www.freifunk-jena.de + diff --git a/files/common/etc/crontabs/root b/files/common/etc/crontabs/root new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/files/common/etc/crontabs/root @@ -0,0 +1 @@ + diff --git a/files/common/etc/dropbear/authorized_keys b/files/common/etc/dropbear/authorized_keys new file mode 100644 index 0000000..ed898bc --- /dev/null +++ b/files/common/etc/dropbear/authorized_keys @@ -0,0 +1,8 @@ +# egon0 (Freifunk Jena) egon@resonar.de +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwgEYvNnufy2ytpbEfKzbcpj0Ax7xJj1E4DtdCufkrBUfrcnR4Skeq3kGrA74+4ihV5msAqwU/NlWTiyPIiOYBqo9zQx2ynF1n40RgqutzFY1rm1z4iop/9cvqFtWBgOEApDd3WxvDlq/QTcVsxoSu4yk9k/ufu5gdLGFlsGPK9etfEw02w81nGOdbpdWiFu+m19qSaR1gNB6DJF/HEuRZI/rgUQA6mndhA4C5oGtMW8ZlIg3FsrDAJdjZKerxwNaJ7SJC7d8/Rc8w8mYeOdr2aQnzIvy8dT8jmahTuxGpwwPrYo4q4mylbjWU8o21ip2G9lfLEA5iAip7Giuin2oJw== +# Darkeye (Freifunk Jena) martinmichel@die-guten-partei.de +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAufrdEwZmNJhcdxBkBepD/cjCkrxTdM6nC7MtommvbyrivRg8Wc56qNXyqxVoTQ3Rs/auk01r29ZpNmrAVc0xeKEZEf1Xm9bmgMOei/535mssPdqVnH+xWq5xdBAYbBPa01xkWTxBHPWqhy/EtzrFHMk6lYMyMIB1iB+hMbT5U8KYaX9geD9dWZ2Ch5cPRpls1AKvfL0LMOo+sVjDK6DxkUHWBtXmsssF5shas20paqWUzj/noYdzAV7B0lZaavKDJ37gJrEo6V0aDTzXaLVNPp8V6wCuMxhzuMrK9JPooeSAABmEqfVIYUDrGsV/uV76tgCd3Saw7DUrSsnFBVS8ow== +# Darkeye (Freifunk Jena) - mobile +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB7QDvtIcbm2u4bnMVrQro+iFkQEsAHC/nbk8I/V85CpZObiofVWD7xJd/UMU9zxhWJ2UG+aVThNX9vwSHfmBYMfMljFXIRG8vo94uVZmEUvgfMDXAoOE7EhLBXGAx+Z1f4/rwoTWE0b/Nb/CfnxfDTbNYQgrjx9pyMY6CtYMddqjsBmq9ZzO/w4+WUZJXIy7imWkKna7czG20AMUNuo7AvcOlU1rgZIVyi2hN31DvuJNLSDXSDCkxMwcV0iukYnNiGk7N/xReBLKHbp9aUk0/TOr+H7cBjQwkXZPheoPsq3CZfolHQiQxjMGwFQlw+ZnrURDaOGFU6u1sAWZDwj2DaFh4YFaPHH8gKJvsE0vjxzWCc3vmFctCLwGLeLoc7Ghz35q066LX9i972w9HQ1YRcrKLAGDmhkzAQqaX3dT7bsgvylTi+nvhr0iYZ9wg44TDd+KGfm+BHtXOxCmr4MzJWOooQi83gr7ZoqGL3rwK8t2dDDORA9sb6sAe+Srj0GXUxbIRWmJY99JOlIocBGRzsUQ08kulsNryQrgk5iwxqSZy0TAGVisZ2Uz5SfNSYbpKLn3IbNtl2TPvFazdMb0RfXhZpcxoPgbf6UmQBQJdI11e6ga6Evn5KIIT6GvtQQDxwdyn/CggEbnXj20nAp8== +# egon0 (Freifunk Jena) - mobile +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDYdPDqvxN2+oZQr1QEAgcpFgRq7QAk6lNT4f5mFiDII07tlx7KMgWGX5C3hbgHpJgVWXx9uC5aB0qQOO8h0KV0AODQDz9bu7P9SvmpZt0isXzV5jh+b/lzMfwlzZt0tmqOUxzN6JkzBfsaQjMEViSsu/bhQG0nPehiEVykrJeMVPngX9hfA6UMj04hhkUY0bG+ET1JpUCSSXKkvPJHKOfGa9gPeZewSasGnxjwzQ5M2Ikn4CtQuDCIrVnjEvb/rAH3So9TSjV31dx10O6vYY2qAnS/oviQSN9NP729CQLSCaBFv4Z5I7WJaXAxkYSRvC8fzTq62nOXWi3rWg2jfSnsbyEkqQGJ5z6ZaiDIi2tHuXfVoLlCdnaVmgPtQuhGQLamrnOvvn+PJBptPgGWl74g/H/UEsT0v60c6jgfp5jtrEk25Bgk7QITp/aykRf6uGjEfwnatZSs43D2y9TU6EPH0oy2tN0MI+XKU2PwoXme1BwAhpKPawnNY495BmLqyn0u3Fr8C1IqD2nCaLhk8OGVEW3BZAy2wdb2V1huTq0SkEMhILrDLKslZwGpO2mtMRrHwAhk6S220zSOH+B9seNK7P42pNBc0pqP6rJrVRxfjpq/+fA4wjE+ojQagQhTAHuK/SsA79gE/vTtlRGOy2nW7D5hmidaiiqptTxuTENULQ== galaxy diff --git a/files/common/etc/hotplug.d/iface/22-wan_led b/files/common/etc/hotplug.d/iface/22-wan_led new file mode 100644 index 0000000..061a499 --- /dev/null +++ b/files/common/etc/hotplug.d/iface/22-wan_led @@ -0,0 +1,15 @@ +#!/bin/sh +case "${ACTION:-ifup}" in + ifup) + gpioctl set 3 + uci set batman-adv.bat0.gw_mode=server + uci commit batman-adv + /etc/init.d/batman-adv restart + ;; + ifdown) + gpioctl dirout 3 + uci set batman-adv.bat0.gw_mode=client + uci commit batman-adv + /etc/init.d/batman-adv restart + ;; +esac diff --git a/files/common/etc/init.d/batman-adv b/files/common/etc/init.d/batman-adv new file mode 100755 index 0000000..6ecb7ea --- /dev/null +++ b/files/common/etc/init.d/batman-adv @@ -0,0 +1,103 @@ +#!/bin/sh /etc/rc.common +START=90 + +is_module_loaded() { + + if [ ! -d "/sys/module/batman_adv" ]; then + echo "batman-adv module directory not found - was the kernel module loaded ?" >&2 + return 0 + fi + + return 1 +} + +start_mesh () { + local meshif="$1" + local interfaces orig_interval log_level aggregated_ogms bonding vis_mode + + is_module_loaded + [ $? -ne 1 ] && return + + config_get interfaces "$meshif" interfaces + config_get orig_interval "$meshif" orig_interval + config_get log_level "$meshif" log_level + config_get aggregated_ogms "$meshif" aggregated_ogms + config_get bonding "$meshif" bonding + config_get gw_mode "$meshif" gw_mode + + config_get vis_mode "$meshif" vis_mode + + if [ "$interfaces" = "" ]; then + echo Error, you must specify at least a network interface + return + fi + + for interface in $interfaces + do + [ ! -f "/sys/class/net/$interface/batman_adv/mesh_iface" ] && echo "Can't add interface $interface - ignoring" && continue + echo $meshif > /sys/class/net/$interface/batman_adv/mesh_iface + done + + if [ $orig_interval ]; then + echo $orig_interval > /sys/class/net/$meshif/mesh/orig_interval + fi + + if [ $log_level ]; then + echo $log_level > /sys/class/net/$meshif/mesh/log_level 2>&- + fi + + if [ $aggregated_ogms ]; then + echo $aggregated_ogms > /sys/class/net/$meshif/mesh/aggregated_ogms + fi + + if [ $bonding ]; then + echo $bonding > /sys/class/net/$meshif/mesh/bonding + fi + + if [ $vis_mode ]; then + echo $vis_mode > /sys/class/net/$meshif/mesh/vis_mode + fi + + if [ $gw_mode ]; then + echo $gw_mode > /sys/class/net/$meshif/mesh/gw_mode + fi +} + +stop_mesh() { + local meshif="$1" + + is_module_loaded + [ $? -ne 1 ] && return + + for iface in $(ls /sys/class/net/*) + do + [ ! -f "$iface/batman_adv/mesh_iface" ] && continue + [ "$(head -1 $iface/batman_adv/mesh_iface)" != "status: $meshif" ] && continue + + echo "none" > $iface/batman_adv/mesh_iface + done +} + +# can also be used with "batman-adv start bat0" +start() { + config_load batman-adv + + if [ -n "$1" ]; then + start_mesh $1 + else + config_foreach start_mesh mesh + fi +} + +# can also be used with "batman-adv stop bat0" +stop () { + config_load batman-adv + + if [ -n "$1" ]; then + stop_mesh $1 + else + config_foreach stop_mesh mesh + fi +} + + diff --git a/files/common/etc/init.d/dnsmasq b/files/common/etc/init.d/dnsmasq new file mode 100755 index 0000000..1b934c0 --- /dev/null +++ b/files/common/etc/init.d/dnsmasq @@ -0,0 +1,386 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2007 OpenWrt.org + +START=60 +DNS_SERVERS="" +DOMAIN="" + +dhcp_calc() { + local ip="$1" + local res=0 + + while [ -n "$ip" ]; do + part="${ip%%.*}" + res="$(($res * 256))" + res="$(($res + $part))" + [ "${ip%.*}" != "$ip" ] && ip="${ip#*.}" || ip= + done + echo "$res" +} + +append_bool() { + local section="$1" + local option="$2" + local value="$3" + local _loctmp + config_get_bool _loctmp "$section" "$option" 0 + [ $_loctmp -gt 0 ] && append args "$value" +} + +append_parm() { + local section="$1" + local option="$2" + local switch="$3" + local _loctmp + config_get _loctmp "$section" "$option" + [ -z "$_loctmp" ] && return 0 + append args "$switch $_loctmp" +} + +append_server() { + append args "-S $1" +} + +append_interface() { + local ifname=$(uci_get_state network "$1" ifname "$1") + append args "-i $ifname" +} + +append_notinterface() { + local ifname=$(uci_get_state network "$1" ifname "$1") + append args "-I $ifname" +} + +append_addnhosts() { + append args "-H $1" +} + +append_bogusnxdomain() { + append args "-B $1" +} + +dnsmasq() { + local cfg="$1" + append_bool "$cfg" authoritative "-K" + append_bool "$cfg" nodaemon "-d" + append_bool "$cfg" domainneeded "-D" + append_bool "$cfg" filterwin2k "-f" + append_bool "$cfg" nohosts "-h" + append_bool "$cfg" nonegcache "-N" + append_bool "$cfg" strictorder "-o" + append_bool "$cfg" logqueries "-q" + append_bool "$cfg" noresolv "-R" + append_bool "$cfg" localise_queries "-y" + append_bool "$cfg" readethers "-Z" + append_bool "$cfg" dbus "-1" + append_bool "$cfg" boguspriv "-b" + append_bool "$cfg" expandhosts "-E" + append_bool "$cfg" enable_tftp "--enable-tftp" + append_bool "$cfg" nonwildcard "-z" + + append_parm "$cfg" cachesize "-c" + append_parm "$cfg" dnsforwardmax "-0" + append_parm "$cfg" port "-p" + append_parm "$cfg" ednspacket_max "-P" + append_parm "$cfg" dhcpleasemax "-X" + append_parm "$cfg" "queryport" "-Q" + append_parm "$cfg" "domain" "-s" + append_parm "$cfg" "local" "-S" + config_list_foreach "$cfg" "server" append_server + config_list_foreach "$cfg" "interface" append_interface + config_list_foreach "$cfg" "notinterface" append_notinterface + config_list_foreach "$cfg" "addnhosts" append_addnhosts + config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain + append_parm "$cfg" "leasefile" "-l" + append_parm "$cfg" "resolvfile" "-r" + append_parm "$cfg" "tftp_root" "--tftp-root" + append_parm "$cfg" "dhcp_boot" "--dhcp-boot" + + config_get DOMAIN "$cfg" domain + + config_get_bool readethers "$cfg" readethers + [ "$readethers" = "1" ] && [ -e "/etc/ethers" ] || touch /etc/ethers + + config_get leasefile $cfg leasefile + [ -n "$leasefile" ] && [ -e "$leasefile" ] || touch "$leasefile" + config_get_bool cachelocal "$cfg" cachelocal 1 + + config_get hostsfile "$cfg" dhcphostsfile + [ -e "$hostsfile" ] && append args "--dhcp-hostsfile=$hostsfile" + + local rebind + config_get_bool rebind "$cfg" rebind_protection 1 + [ $rebind -gt 0 ] && { + logger -t dnsmasq \ + "DNS rebinding protection is active," \ + "will discard upstream RFC1918 responses!" + append args "--stop-dns-rebind" + + local rebind_localhost + config_get_bool rebind_localhost "$cfg" rebind_localhost 0 + [ $rebind_localhost -gt 0 ] && { + logger -t dnsmasq "Allowing 127.0.0.0/8 responses" + append args "--rebind-localhost-ok" + } + + append_rebind_domain() { + logger -t dnsmasq "Allowing RFC1918 responses for domain $1" + append args "--rebind-domain-ok=$1" + } + + config_list_foreach "$cfg" rebind_domain append_rebind_domain + } +} + +dhcp_subscrid_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get subscriberid "$cfg" subscriberid + [ -n "$subscriberid" ] || return 0 + + append args "--dhcp-subscrid=$networkid,$subscriberid" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_remoteid_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get remoteid "$cfg" remoteid + [ -n "$remoteid" ] || return 0 + + append args "--dhcp-remoteid=$networkid,$remoteid" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_circuitid_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get circuitid "$cfg" circuitid + [ -n "$circuitid" ] || return 0 + + append args "--dhcp-circuitid=$networkid,$circuitid" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_userclass_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get userclass "$cfg" userclass + [ -n "$userclass" ] || return 0 + + append args "--dhcp-userclass=$networkid,$userclass" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_vendorclass_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get vendorclass "$cfg" vendorclass + [ -n "$vendorclass" ] || return 0 + + append args "--dhcp-vendorclass=$networkid,$vendorclass" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_host_add() { + local cfg="$1" + + config_get name "$cfg" name + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" + + config_get ip "$cfg" ip + [ -n "$ip" ] || return 0 + + macs="" + config_get mac "$cfg" mac + for m in $mac; do append macs "$m" ","; done + [ -n "$macs" ] || return 0 + + append args "--dhcp-host=$macs,${networkid:+net:$networkid,}$ip${name:+,$name}" +} + +dhcp_mac_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get mac "$cfg" mac + [ -n "$mac" ] || return 0 + + append args "--dhcp-mac=$networkid,$mac" + + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_boot_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + + config_get filename "$cfg" filename + [ -n "$filename" ] || return 0 + + config_get servername "$cfg" servername + [ -n "$servername" ] || return 0 + + config_get serveraddress "$cfg" serveraddress + [ -n "$serveraddress" ] || return 0 + + append args "--dhcp-boot=${networkid:+net:$networkid,}$filename,$servername,$serveraddress" + + dhcp_option_add "$cfg" "$networkid" +} + + +dhcp_add() { + local cfg="$1" + config_get net "$cfg" interface + [ -n "$net" ] || return 0 + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || networkid="$net" + + config_get ifname "$net" ifname + [ -n "$ifname" ] || return 0 + + config_get dnsserver "$net" dns + [ "$cachelocal" = "0" -a -n "$dnsserver" ] && { + DNS_SERVERS="$DNS_SERVERS $dnsserver" + } + + append_bool "$cfg" ignore "-2 $ifname" && return 0 + + config_get proto "$net" proto + [ static = "$proto" ] || return 0 + + config_get ipaddr "$net" ipaddr + config_get netmask "$cfg" netmask + [ -n "$netmask" ] || config_get netmask "$net" netmask + + #check for an already active dhcp server on the interface, unless 'force' is set + config_get_bool force "$cfg" force 0 + [ $force -gt 0 ] || { + udhcpc -n -q -s /bin/true -t 1 -i $ifname >&- && { + logger -t dnsmasq \ + "found already running DHCP-server on interface '$ifname'" \ + "refusing to start, use 'option force 1' to override" + return 0 + } + } + + config_get start "$cfg" start + config_get limit "$cfg" limit + config_get start_ip "$cfg" start_ip + config_get end_ip "$cfg" end_ip + config_get leasetime "$cfg" leasetime + config_get options "$cfg" options + config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1 + + leasetime="${leasetime:-12h}" + start="$(dhcp_calc "${start:-100}")" + limit="${limit:-150}" + eval "$(ipcalc.sh $ipaddr $netmask $start $limit)" + if [ "$dynamicdhcp" = "0" ]; then END="static"; fi + if [ -n "$start_ip" ]; then START=$start_ip; fi + if [ -n "$end_ip" ]; then END=$end_ip; fi + append args "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}" + dhcp_option_add "$cfg" "$networkid" +} + +dhcp_option_add() { + local cfg="$1" + local networkid="$2" + + config_get dhcp_option "$cfg" dhcp_option + for o in $dhcp_option; do + append args "-O $networkid","$o" + done + +} + +dhcp_domain_add() { + local cfg="$1" + local ip name names + + config_get names "$cfg" name + [ -n "$names" ] || return 0 + + config_get ip "$cfg" ip + [ -n "$ip" ] || return 0 + + local oIFS="$IFS"; IFS="."; set -- $ip; IFS="$oIFS" + local raddr="${4:+$4.$3.$2.$1.in-addr.arpa}" + + for name in $names; do + local fqdn="$name" + + [ "${fqdn%.*}" == "$fqdn" ] && \ + fqdn="$fqdn${DOMAIN:+.$DOMAIN}" + + append args "-A /$fqdn/$ip" + + [ -n "$raddr" ] && { + append args "--ptr-record=$raddr,$fqdn" + raddr="" + } + done +} + +start() { + include /lib/network + scan_interfaces + config_load dhcp + + args="" + config_foreach dnsmasq dnsmasq + config_foreach dhcp_host_add host + config_foreach dhcp_boot_add boot + config_foreach dhcp_mac_add mac + config_foreach dhcp_vendorclass_add vendorclass + config_foreach dhcp_userclass_add userclass + config_foreach dhcp_circuitid_add circuitid + config_foreach dhcp_remoteid_add remoteid + config_foreach dhcp_subscrid_add subscrid + config_foreach dhcp_domain_add domain + config_foreach dhcp_add dhcp + /usr/sbin/dnsmasq $args && { + rm -f /tmp/resolv.conf + [ -n "$DOMAIN" ] && echo "search $DOMAIN" >> /tmp/resolv.conf + DNS_SERVERS="$DNS_SERVERS 127.0.0.1" + for DNS_SERVER in $DNS_SERVERS ; do + echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf + done + } +} + +stop() { + [ -f /tmp/resolv.conf ] && { + rm -f /tmp/resolv.conf + ln -s /tmp/resolv.conf.auto /tmp/resolv.conf + } + killall dnsmasq + return 0 +} diff --git a/files/common/etc/init.d/n2n b/files/common/etc/init.d/n2n new file mode 100755 index 0000000..26f2e72 --- /dev/null +++ b/files/common/etc/init.d/n2n @@ -0,0 +1,43 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008 OpenWrt.org +[ -n "$IPKG_INSTROOT" ] && exit 0 +START=90 + +config_cb() { + local cfg="$CONFIG_SECTION" + config_get configname "$cfg" TYPE + + case "$configname" in + edge) + config_get ipaddr "$cfg" ipaddr + config_get supernode "$cfg" supernode + config_get port "$cfg" port + config_get community "$cfg" community + config_get key "$cfg" key + config_get_bool route "$cfg" route 0 + config_get devname "$cfg" devname + node_mac=`ifconfig ath0 | grep HWaddr | awk '{print $5}' | tr -d "\n" | cut -c6-` + [ "$route" = "1" ] && args='-r' + if [ "$ipaddr" != "" ]; then + mac_random=`echo $(head -30 /dev/urandom | tr -dc "0123456789" | head -c2)` + edge -f $args -a 169.254.0.1 -d $devname -c $community -k $key -m 12:${mac_random}${node_mac} -l ${supernode}:${port} + ifconfig $devname 0.0.0.0 + batctl if add $devname + fi + ;; + supernode) + config_get port "$cfg" port + if [ "$port" != "" ]; then + supernode -l $port & + fi + ;; + esac +} + +start() { + config_load n2n +} +stop() { + killall -9 edge + killall supernode +} diff --git a/files/common/etc/rc.local b/files/common/etc/rc.local new file mode 100644 index 0000000..38c68a9 --- /dev/null +++ b/files/common/etc/rc.local @@ -0,0 +1,4 @@ +# the system init finished. By default this file does nothing. +ifconfig br-mesh down +ifconfig br-mesh up +exit 0 |