-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathsetup.sh
More file actions
132 lines (106 loc) · 3.09 KB
/
setup.sh
File metadata and controls
132 lines (106 loc) · 3.09 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
echo "[*] Setting Hostname..."
echo "[*][*] Writing to /etc/hosts"
cat > /etc/hosts <<- EOF
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 LongRangeReader
EOF
hostname LongRangeReader
echo "[*][*] Writing to /etc/hostname"
echo "LongRangeReader" > /etc/hostname;
echo "[*] Installing Packages..."
apt-get update;
apt-get install -y git screen pigpio python-pip isc-dhcp-server hostapd;
pip install tornado pigpio;
echo "[*] Writing Configs..."
echo "[*][*] Writing to /etc/network/interfaces"
cat > /etc/network/interfaces <<- EOM
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet static
post-up /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf
post-up service isc-dhcp-server restart
address 192.168.3.1
netmask 255.255.255.0
EOM
echo "[*][*] Writing to /etc/dhcp/dhcpd.conf"
cat > /etc/dhcp/dhcpd.conf <<- EOM
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.2 192.168.3.50;
option broadcast-address 192.168.3.255;
option routers 192.168.3.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
EOM
echo "[*][*] Writing to /etc/default/isc-dhcp-server"
cat > /etc/default/isc-dhcp-server <<- EOM
INTERFACES="wlan0"
EOM
echo "[*][*] Writing to /etc/hostapd/hostapd.conf"
cat > /etc/hostapd/hostapd.conf <<- EOM
interface=wlan0
driver=nl80211
ssid=LongRangeReader
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=accessgranted
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOM
echo "[*][*] Writing to /etc/default/hostapd"
cat > /etc/default/hostapd <<- EOM
DAEMON_OPTS="/etc/hostapd/hostapd.conf"
EOM
echo "[*] Writing boot files - /etc/rc.local"
cat > /etc/rc.local <<- EOM
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=\$(hostname -I) || true
if [ "\$_IP" ]; then
printf "My IP address is %s\n" "\$_IP"
fi
# Start pigpio daemon
pigpiod
# Start long range reader script
screen -dmS lrr_wiegand_listener bash -c "cd /opt/LongRangeReader; su -c 'python ./lrr_wiegand_listener.py'"
screen -dmS lrr_webserver bash -c "cd /opt/LongRangeReader; su -c 'python ./lrr_webserver.py'"
exit 0
EOM
echo "[*] Installing LongRangeReader code to /opt/LongRangeReader/..."
mkdir /opt/;
cd /opt/;
git clone git@github.com:linuz/LongRangeReader.git
echo "[*] Enabling hostapd on startup"
sudo update-rc.d hostapd defaults
echo "[*] Restarting Raspberry Pi in 10 seconds."
sleep 10;
reboot