#!/bin/sh # path to the configure files conf_dir=/appset/conf # configure files hostapd_conf_file=${conf_dir}/hostapd.conf udhcpd_conf_file=${conf_dir}/udhcpd.conf # set ip & netmask of wlan0, then start up wlan0 ifconfig wlan0 11.1.1.1 netmask 255.255.255.0 up ifconfig sleep 1 ps w |grep "hostapd"|grep -v grep if [ $? -eq 0 ] ; then echo "hostapd is already running." kill -9 `ps | grep "hostapd" | grep -v "grep" | awk '{print $1}'` sleep 1 echo "try to start hostapd." hostapd ${hostapd_conf_file} -B sleep 1 else echo "try to start hostapd." hostapd ${hostapd_conf_file} -B sleep 1 fi mkdir -p /tmp/var/lib/misc/ touch /tmp/var/lib/misc/udhcpd.leases ps w |grep "udhcpd"|grep -v grep|grep -v "udhcpd_" if [ $? -eq 0 ] ; then echo "udhcpd is already running." kill -9 `ps | grep "udhcpd" | grep -v "grep" | awk '{print $1}'` echo "try to start udhcpd." udhcpd -S ${udhcpd_conf_file} & sleep 1 else echo "try to start udhcpd." udhcpd -S ${udhcpd_conf_file} & sleep 1 fi ps w #route del default #route add default gw 192.168.4.1 dev eth0 route sh -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf" cat /etc/resolv.conf echo "ip_forward" echo 1 > /proc/sys/net/ipv4/ip_forward cat /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE echo "wifi_sap config end"