#!/bin/bash # # Scaredycat's simple gta01 setup script # # local ip config # LOCAL_IP='192.168.0.200' LOCAL_NM='255.255.255.0' # # ip address of neo # NEO_IP='192.168.0.202' # # set the port that the neo is connected on and the user we drop to # P_USB='usb0' USER='nobody' # # set other dnrd params # # # don't use my local hosts file # USE_HOSTS='-moff' # # debug level, just so you can see it working. make it '' # to turn off debug mode and fork # DEBUG='-d3' # # ******************************************************************* # ****** You don't need to fiddle with anything below this line ***** # ******************************************************************* # # configure external apps # IFCONFIG=`which ifconfig` DNRD=`which dnrd` IPTABLES='iptables' ROUTE='/sbin/route' # split ip for foo in 1 2 3 4; do IPADDR[$foo]=`echo ${LOCAL_IP}|cut -d"." -f$foo` done #split mask for foo in 1 2 3 4; do MASK[$foo]=`echo ${LOCAL_NM}|cut -d"." -f$foo` done for foo in 1 2 3 4; do NETADDR[$foo]=$((${IPADDR[$foo]} & ${MASK[$foo]})) BROADCAST[$foo]=$((${NETADDR[$foo]} | $((${MASK[$foo]} ^255)))) done NETWORK="${NETADDR[1]}.${NETADDR[2]}.${NETADDR[3]}.${NETADDR[4]}" ${IFCONFIG} ${P_USB} ${LOCAL_IP} netmask ${LOCAL_NM} ${ROUTE} add -host ${NEO_IP}/32 dev ${P_USB} ${IPTABLES} -A POSTROUTING -t nat -j MASQUERADE -s ${NETWORK}/24 echo 1 > /proc/sys/net/ipv4/ip_forward ${IPTABLES} -P FORWARD ACCEPT # read current resolv.conf and get nameservers # S_LIST=`cat /etc/resolv.conf | grep nameserver | sed 's/nameserver /-s/'` S_PARAMS=' ' for S_ITEM in ${S_LIST} do S_PARAMS="${S_PARAMS} ${S_ITEM}" done # # run dnrd with all the params # if [ -n ${LOCALIP} ] ; then ${DNRD} -a ${LOCAL_IP} ${S_PARAMS} -u${USER} ${DEBUG} ${USE_HOSTS} fi