add script of wifif config for raspberry pi master
authorPeng Li <seudut@gmail.com>
Mon, 27 Aug 2018 12:02:48 +0000 (20:02 +0800)
committerPeng Li <seudut@gmail.com>
Mon, 27 Aug 2018 12:02:48 +0000 (20:02 +0800)
bin/startHostapd.sh [new file with mode: 0755]
bin/stopHostapd.sh [new file with mode: 0755]
zsh/zshrc

diff --git a/bin/startHostapd.sh b/bin/startHostapd.sh
new file mode 100755 (executable)
index 0000000..510ba47
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash -xe
+
+# This tool is to enable Hotspot mode on Raspberry Pi
+# Refer https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md#internet-sharing
+
+# disable WiFi connection
+wpa_cli -i wlan0 disable_network 0 || true
+
+# Stop dhcp cliennt, will start it with static IP and no wpa_supplicant
+systemctl stop dhcpcd || true
+killall dhcpcd || true
+
+# start Hostapd mode
+systemctl start hostapd
+
+# start dhcp client with static IP
+dhcpcd --static ip_address=192.168.4.1/24 --nohook wpa_supplicant wlan0
+
+# start dnsmasq, dns server with IP reanges
+dnsmasq --interface=wlan0 --dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
diff --git a/bin/stopHostapd.sh b/bin/stopHostapd.sh
new file mode 100755 (executable)
index 0000000..c20b12a
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash -xe
+
+# stop hostapd
+systemctl stop hostapd || true
+
+# stop dns server
+killall dnsmasq || true
+
+# stop dhcp client
+killall dhcpcd || true
+
+sleep 1
+
+# start dhcp
+dhcpcd
+
+sleep 3
+
+# scan wifi
+wpa_cli -i wlan0 scan
index c6dd499..994bd71 100644 (file)
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -295,6 +295,7 @@ export MANPATH=$MANPATH:/usr/local/man
 
 export MANPATH=$MANPATH:${HOME}/perl5/man
 export PATH=$PATH:"${HOME}/scripts"
+export PATH=$PATH:"/sbin:/usr/sbin"
 ## hunspell path
 export DICPATH="/usr/local/share/hunspell/"