Initial commit

This commit is contained in:
Jon-Paul Story
2026-08-29 23:29:06 -05:00
commit be3c4a1214
6 changed files with 130 additions and 0 deletions
Vendored
BIN
View File
Binary file not shown.
Binary file not shown.
Executable
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
#
# This version uses September 2017 august stretch image, please use this image
#
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
if [[ $# -lt 1 ]];
then echo "You need to pass a password!"
echo "Usage:"
echo "sudo $0 yourChosenPassword [apName]"
exit
fi
APPASS="$1"
APSSID="rPi3"
if [[ $# -eq 2 ]]; then
APSSID=$2
fi
apt-get remove --purge hostapd -yqq
apt-get update -yqq
apt-get upgrade -yqq
apt-get install hostapd dnsmasq -yqq
cat > /etc/dnsmasq.conf <<EOF
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h
EOF
cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlan0
hw_mode=g
channel=10
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
wpa_passphrase=$APPASS
ssid=$APSSID
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
EOF
sed -i -- 's/allow-hotplug wlan0//g' /etc/network/interfaces
sed -i -- 's/iface wlan0 inet manual//g' /etc/network/interfaces
sed -i -- 's/ wpa-conf \/etc\/wpa_supplicant\/wpa_supplicant.conf//g' /etc/network/interfaces
sed -i -- 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd
cat >> /etc/network/interfaces <<EOF
# Added by rPi Access Point Setup
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
EOF
echo "denyinterfaces wlan0" >> /etc/dhcpcd.conf
systemctl enable hostapd
systemctl enable dnsmasq
sudo service hostapd start
sudo service dnsmasq start
echo "All done! Please reboot"
Executable
+14
View File
@@ -0,0 +1,14 @@
const BeaconScanner = require('node-beacon-scanner');
const scanner = new BeaconScanner();
var fs = require('fs');
// Set an Event handler for becons
scanner.onadvertisement = (ad) => {
console.log(JSON.stringify(ad, null, ' '));
};
// Start scanning
scanner.startScan().then(() => {
console.log('Started to scan.') ;
}).catch((error) => {
console.error(error);
});
Executable
+13
View File
@@ -0,0 +1,13 @@
value=$( gpio read 15 )
if [ $value -gt 0 ]
then
# sudo killall watchall.sh
sudo kill -9 $(ps ax | grep "sudo /home/pi/watchall.sh" | grep v grep | awk '{print $1}')
sudo kill -9 $(ps ax | grep "sudo node app.js" | grep -v grep | awk '{print $1}')
sudo kill -9 $(ps ax | grep "node app.js" | grep -v grep | awk '{print $1}')
sudo kill -9 $(ps ax | grep "sh /home/pi/watchall.sh" | grep -v grep | awk '{print $1}')
sudo kill -9 $(ps ax | grep "tail -fn0 node.txt" | grep -v grep | awk '{print $1}')
sleep 10
#gpio write 7 1
sudo /home/pi/watchall.sh
fi
Executable
+29
View File
@@ -0,0 +1,29 @@
cd /home/pi/
rm node.txt
touch node.txt
gpio mode 15 out
gpio mode 8 out
gpio write 8 1
gpio write 15 0
gpio mode 7 out
gpio write 7 1
sudo node app.js | ts '[%Y-%m-%d %H:%M:%S]' > node.txt &
tail -fn0 node.txt | \
while read line ; do
echo "$line" | grep "12345678-9123-4567-8912-345678912345"
if [ $? = 0 ]
then
# sudo kill -9 $(ps ax | grep "node app.js" | grep -v grep | awk '{print $1}')
# gpio write 7 0
# gpio write 8 0
# sleep 5
# gpio write 7 1
gpio write 15 1
# sudo kill -9 $(ps ax | grep "tail -fn0 node.txt" | grep -v grep | awk '{print $1}')
curl http://10.0.1.246/state.xml?extvar0=1
sleep 10
curl http://10.0.1.246/state.xml?extvar0=0
echo "We got a hit" | ts '[%Y-%m-%d %H:%M:%S]' >> hits.txt
./checker.sh
fi
done