Italiano English
Modifica History Actions

NinuxUciScriptHotSpot

Ninux Uci Script HOTSPOT

This is the first version of "HotSpot Gang Bang". Is not tested, and not complete yet !

set -a

/etc/init.d/dnsmasq start
/etc/init.d/dnsmasq enable

/etc/init.d/firewall stop
/etc/init.d/firewall disable

HOSTNAME="GREG1"
LANIP=10.177.1.1
LANNET=10.177.1.0
LANMASK=255.255.255.0
LANGW=""

VPNIP=10.0.1.177 

CHANNEL="8"
ESSID="www.ninux.org"


sysctl -w kernel.hostname=$HOSTNAME
uci set system.@system[0].hostname=$HOSTNAME

DEVICE=`uci get wireless.@wifi-iface[0].device`
uci delete wireless.$DEVICE.disabled

#disable default bridge on lan
#uci delete network.lan.type

uci set network.lan.proto=static
uci set network.lan.ipaddr=$LANIP
uci set network.lan.netmask=$LANMASK
uci set network.lan.gateway=$LANGW
uci set network.lan.dns=8.8.8.8
uci set network.lan.device=$DEVICE

uci set network.wan=interface
uci set network.wan.ifname=eth0
uci set network.wan.proto=dhcp

uci set network.vpn=interface
uci set network.vpn.ifname=ninux
uci set network.vpn.proto=none

#TODO: move this config to variables on top of script
uci set network.wlan=interface
uci set network.wlan.proto=static
uci set network.wlan.ipaddr=$WLANIP
uci set network.wlan.netmask=255.255.255.0

uci set wireless.$DEVICE.channel=$CHANNEL
uci set wireless.$DEVICE.disabled=0
#uci set wireless.$DEVICE.txpower=20

uci set wireless.@wifi-iface[0].network=wlan
uci set wireless.@wifi-iface[0].mode=ap
uci set wireless.@wifi-iface[0].ssid=$ESSID
uci set wireless.@wifi-iface[0].encryption=none
uci set wireless.@wifi-iface[0].bgscan=0

rm /etc/config/olsrd
touch /etc/config/olsrd
uci add olsrd olsrd
uci set olsrd.@olsrd[0].IpVersion=4
uci set olsrd.@olsrd[0].DebugLevel=0
uci add olsrd LoadPlugin
uci set olsrd.@LoadPlugin[0]=LoadPlugin
uci set olsrd.@LoadPlugin[0].library=olsrd_txtinfo.so.0.1
uci set olsrd.@LoadPlugin[0].accept="0.0.0.0"
uci add olsrd Interface
uci set olsrd.@Interface[0]=Interface
uci set olsrd.@Interface[0].interface=vpn
uci set olsrd.@Interface[0].LinkQualityMult='default 0.2'

uci add olsrd Hna4
uci set olsrd.@Hna4[-1].netaddr=$LANNET
uci set olsrd.@Hna4[-1].netmask=$LANMASK
uci set olsrd.@LoadPlugin[0]=LoadPlugin
uci set olsrd.@LoadPlugin[0].library=olsrd_mdns.so.1.0.0
uci set olsrd.@LoadPlugin[0].NonOlsrIf=lan

rm /etc/config/mini_snmpd
touch /etc/config/mini_snmpd
uci add mini_snmpd mini_snmpd
uci set mini_snmpd.@mini_snmpd[0].enabled=1
uci set mini_snmpd.@mini_snmpd[0].community=public
uci set mini_snmpd.@mini_snmpd[0].location=''
uci set mini_snmpd.@mini_snmpd[0].contact=''
uci set mini_snmpd.@mini_snmpd[0].interfaces=ninux,$DEVICE

uci commit

/etc/init.d/mini_snmpd enable

[ -x /etc/init.d/olsrd ] && /etc/init.d/olsrd enable

rm /etc/init.d/tincd
touch /etc/init.d/tincd
chmod +x /etc/init.d/tincd
cat > /etc/init.d/tincd <<EOF
#!/bin/sh /etc/rc.common
START=50

start() {
tincd -n ninux
}

stop() {

killall tincd

}

EOF


touch /etc/tinc/ninux/tinc-up
chmod +x /etc/tinc/ninux/tinc-up
cat > /etc/tinc/ninux/tinc-up <<EOF

ip link set dev ninux up
ip a a dev ninux $VPNIP/24 broadcast 10.0.1.255
#Adjust MTU
ip link set mtu 1280 dev ninux
iptables -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
#hotspot
grep relakks /etc/iproute2/rt_tables || echo 200 relakks >> /etc/iproute2/rt_tables
ip rule add from $LANNET/24 table relakks
ip route add $LANNET/24 dev wlan0 table relakks
ip route add default via 10.0.1.1 table relakks

EOF