-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhosHome.sh
executable file
·71 lines (58 loc) · 1.86 KB
/
whosHome.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
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
#!/bin/bash
while true
do
#This runs an arp scan and lists all of the mac addresses on my network
sudo arp-scan -l > arpScan.txt
#We then have a series of if statements to check for my housmates Mac addresses
if grep -q 82:af:0b:d7:c9:65 arpScan.txt
then
occupant1="Nelly"
else
#If the MAC address is not found then we will write and empty string to the variable
occupant1=""
fi
if grep -q b2:60:77:57:c7:3e arpScan.txt
then
occupant2="Will"
else
occupant2=""
fi
if grep -q e4:a7:c5:e4:85:ca arpScan.txt
then
occupant3="Andrew"
else
occupant3=""
fi
#you can edit the code to add as many if else statements as you need to check for every mac address you have
#I have added some extra lines below that you can add more addresses with. Just uncomment them if you are using them.
if grep -q 6e:89:35:c9:16:5f arpScan.txt
then
occupant4="Zoe"
else
occupant4=""
fi
#if grep -q xx:xx:xx:xx:xx:xx arpScan.txt
#then
# occupant5="Sarah"
#else
# occupant5=""
#fi
#if grep -q xx:xx:xx:xx:xx:xx arpScan.txt
#then
# occupant6="Romina"
#else
# occupant6=""
#fi
echo "Occupant 1 ${occupant1}"
echo "Occupant 2 ${occupant2}"
echo "Occupant 3 ${occupant3}"
#echo "Occupant 4 ${occupant4}"
#echo "Occupant 5 ${occupant5}"
#echo "Occupant 6 ${occupant6}"
#We then output some html code to a file to be served on the webserver on the pi
echo "<link rel="stylesheet" href="style.css">
<h1 class="title">Who's Home?<img src="https://img.icons8.com/fluency/48/000000/home.png"/></h1><h1>$occupant1 <br>$occupant2<br> $occupant3 <br>$occupant4<br></h1>" > /var/www/html/index.nginx-debian.html
#We then want the program to sleep for 5 minutes before scanning the network again.
#You can adjust this time but beware of flooding the network with traffic if repeated too frequently
sleep 5m
done