-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·44 lines (35 loc) · 911 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
if [ -L $0 ]
then
BASE_DIR=`dirname $(readlink $0)`
else
BASE_DIR=`dirname $0`
fi
basepath=$(cd $BASE_DIR; pwd)
echo ${basepath}
echo "Stopping network services..."
service dhcpcd stop
service dnsmasq stop
echo "Adding uap0 interface to wlan0..."
ip link ls up | grep -q 'uap0' &> /dev/null
if [ $? == 0 ]; then
iw dev uap0 del
fi
iw dev wlan0 interface add uap0 type __ap
echo "Set ip to uap0..."
ifconfig uap0 up 192.168.50.1/24
echo "ln dnsmasq and hostapd conf..."
ln -s ${basepath}/dnsmasq.conf /etc/dnsmasq.d/raspap.conf
ln -s ${basepath}/hostapd.conf /etc/hostapd/raspap.conf
echo "Enable ip forward..."
sysctl -w net.ipv4.ip_forward=1
echo "Setting iptables..."
iptables -t nat -A POSTROUTING -j MASQUERADE
echo "Starting AP..."
hostapd -B /etc/hostapd/raspap.conf
sleep 3
echo "Restarting network services..."
service dnsmasq start
sleep 3
service dhcpcd start
sleep 3