-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-adhoc
executable file
·50 lines (43 loc) · 1.1 KB
/
setup-adhoc
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
45
46
47
48
49
50
#!/bin/bash
# Initalize/join Ad-hoc network
# Place this script in /usr/local/bin on the Pi-Pucks
# Running this script will disable internet connection
# Optional Inputs: ID and network IF
# Run as SUDO
[ "$UID" -eq 0 ] || exec sudo bash "$0" "$@"
ID_FILE="/boot/pi-puck_id"
if test -f "$ID_FILE"; then
# Pi-Puck ID and network IF
ID=$(cat $ID_FILE)
IF=wlan0
echo "Joining Ad-hoc network with Pi-Puck ID $ID"
else
# Monitor-PC ID and network IF
ID="100"
# IF=wlx801f025a9a7f
IF=wlx801f025a9a7b
echo "Joining Ad-hoc network with ID $ID"
fi
# User chosen ID/IF
if [ "$#" -eq 1 ]; then
ID=$1
elif [ "$#" -eq 2 ]; then
ID=$1
IF=$2
echo "Joining Ad-hoc network with ID $ID"
fi
# Disable wpa_supplicant and dhcpcd on the Pi-Pucks
if test -f "$ID_FILE"; then
systemctl stop wpa_supplicant.service
systemctl disable wpa_supplicant.service
systemctl stop dhcpcd.service
systemctl disable dhcpcd.service
fi
# Setup Ad-Hoc Mesh Network
ip link set $IF
iw $IF set type ibss
ifconfig $IF mtu 1499
iwconfig $IF channel 9
ip link set $IF up
iw $IF ibss join AdHocPi 2452
ifconfig $IF 172.27.1.${ID}/16