Skip to content

Commit

Permalink
v1.2 Change interfaces file for each type of Pi. r8188eu drivers are …
Browse files Browse the repository at this point in the history
…notorious for their working with tools like iwconfig, hence fixed setup in the interfaces file might be a way around it.
  • Loading branch information
shantanoo-desai committed Mar 30, 2017
1 parent 971c9ef commit 7f650bd
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions adhoc_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,28 @@ case "$PI_TYPE" in
#!/bin/sh -e
# Ad-Hoc Network creation
echo "Creating Ad-Hoc Network"
iwconfig wlan0 mode ad-hoc essid test-adhoc channel 01 txpower 0
iwconfig wlan0 mode ad-hoc essid test-adhoc channel 01 txpower 3
exit 0
EOF

echo "Changing network/interfaces file.."
cp /etc/network/interfaces /etc/network/interfaces.backup
tee <<- 'EOF' > /etc/network/interfaces
# loopback interface
auto lo
iface lo inet loopback
# ethernet eth0
iface eth0 inet manual
# WLAN wlan0 for Ad Hoc network
# TWIN Node for Pi-3
allow-hotplug wlan0
iface wlan0 inet6 auto
EOF
# here-doc ends for /etc/network/interfaces file

;; # Switch Case for Pi-3 Over

"a01041" | "a21041" | "a22042") # Pi 3 Revision Numbers
Expand All @@ -75,38 +93,35 @@ EOF
#!/bin/sh -e
echo "Creating Ad-Hoc Network"
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc essid test-adhoc channel 01 txpower 0
iwconfig wlan0 mode ad-hoc essid test-adhoc channel 01 txpower 3
ifconfig wlan0 up
exit 0
EOF
# here-doc ends here for /etc/rc.local
echo "Changing network/interfaces file.."
cp /etc/network/interfaces /etc/network/interfaces.backup
tee <<- 'EOF' > /etc/network/interfaces
# loopback interface
auto lo
iface lo inet loopback
# ethernet eth0
iface eth0 inet manual
# WLAN wlan0 for Ad Hoc network
# TWIN Node with rt2x00lib driver
allow-hotplug wlan0
iface wlan0 inet6 auto
EOF
# here-doc ends for /etc/network/interfaces file

elif [[ "$EXT_WLAN_CHIP_2" == "r8188eu" ]]; then # if RTL8188EU driver
echo "ipv6" >> /etc/modules; echo "$EXT_WLAN_CHIP_2" >> /etc/modules
echo
echo "Changing rc.local files.."
cp /etc/rc.local /etc/rc.local.backup
tee <<- 'EOF' > /etc/rc.local
#!/bin/sh -e
echo "Creating Ad-Hoc Network"
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc essid test-adhoc channel 01
# cannot change tx power for r8188eu drivers
# cannot change channel parameters for r8188eu drivers
ifconfig wlan0 up
exit 0
EOF
else
echo "no chipset found.."
exit 1
fi
;; # Switch Case for Pi - 2 ends here
esac

echo
echo "Changing network/interfaces file.."
cp /etc/network/interfaces /etc/network/interfaces.backup
tee <<'EOF' > /etc/network/interfaces
echo "Changing network/interfaces files.."
cp /etc/network/interfaces /etc/network/interfaces.backup
tee <<- 'EOF' > /etc/network/interfaces
# loopback interface
auto lo
iface lo inet loopback
Expand All @@ -115,12 +130,20 @@ iface lo inet loopback
iface eth0 inet manual
# WLAN wlan0 for Ad Hoc network
# TWIN Node
# TWIN Node with r8188eu driver
allow-hotplug wlan0
iface wlan0 inet6 auto
wireless-channel 01
wireless-mode ad-hoc
wireless-essid test-adhoc
EOF
# here-doc ends for /etc/network/interfaces file
# here-doc for /etc/network/interfaces file for r8188eu driver ends here
else
echo "no chipset found.."
exit 1
fi
;; # Switch Case for Pi - 2 ends here
esac

echo
echo "Changing other network configurations.."
Expand Down

0 comments on commit 7f650bd

Please sign in to comment.