Adding more setup files for device registration, more scripts, and hostapd-psk list...
authorrtrimana <rtrimana@uci.edu>
Fri, 16 Jun 2017 18:55:59 +0000 (11:55 -0700)
committerrtrimana <rtrimana@uci.edu>
Fri, 16 Jun 2017 18:55:59 +0000 (11:55 -0700)
sentinel_setup/config/dhcp
sentinel_setup/config/hostapd-psk [new file with mode: 0644]
sentinel_setup/config/wireless
sentinel_setup/register/README [new file with mode: 0644]
sentinel_setup/register/devices.dat [new file with mode: 0644]
sentinel_setup/register/register_device.sh [new file with mode: 0755]
sentinel_setup/setup/dhcp [new file with mode: 0755]

index acba5d9167f9524aace3693ac1b5f48d06938add..ddd0548ae52f26f3820e7d09ff48b7913f8c9584 100644 (file)
@@ -34,3 +34,63 @@ config odhcpd 'odhcpd'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
 
+# RaspberryPi4
+config host
+        option ip '192.168.1.192'
+        option mac '74:da:38:0d:05:56'
+
+# RaspberryPi2
+config host
+        option ip '192.168.1.191'
+        option mac '74:da:38:0d:05:55'
+
+# RaspberryPi1
+config host
+        option ip '192.168.1.108'
+        option mac '74:da:38:68:72:8a'
+
+# Android Phone
+config host
+        option ip '192.168.1.50'
+        option mac '64:bc:0c:43:3f:40'
+
+# Amcrest Camera 1
+config host
+        option ip '192.168.1.195'
+        option mac '3c:ef:8c:7f:c0:19'
+
+# Amcrest Camera 2
+config host
+        option ip '192.168.1.196'
+        option mac '3c:ef:8c:6f:79:5a'
+
+# iHome Speaker 1
+config host
+        option ip '192.168.1.119'
+        option mac 'c8:d5:fe:e6:ad:96'
+
+# iHome Speaker 2
+config host
+        option ip '192.168.1.234'
+        option mac 'c8:d5:fe:e6:a2:d8'
+
+# ESP board
+config host
+        option ip '192.168.1.222'
+        option mac '18:fe:34:db:59:72'
+
+# Lifx light bulb 1
+config host
+        option ip '192.168.1.126'
+        option mac 'd0:73:d5:12:8e:30'
+
+# Lifx light bulb 2
+config host
+        option ip '192.168.1.232'
+        option mac 'd0:73:d5:02:41:da'
+
+# WeMo
+config host
+        option ip '192.168.1.145'
+        option mac '94:10:3e:36:60:09'
+
diff --git a/sentinel_setup/config/hostapd-psk b/sentinel_setup/config/hostapd-psk
new file mode 100644 (file)
index 0000000..18a3b9d
--- /dev/null
@@ -0,0 +1,12 @@
+74:da:38:0d:05:56 1qaz2wsx3edcPi4
+74:da:38:0d:05:55 1qaz2wsx3edcPi2
+74:da:38:68:72:8a 1qaz2wsx3edcPi1
+64:bc:0c:43:3f:40 1qaz2wsx3edcPhone
+3c:ef:8c:7f:c0:19 1qaz2wsx3edcCam1
+3c:ef:8c:6f:79:5a 1qaz2wsx3edcCam2
+c8:d5:fe:e6:ad:96 1qaz2wsx3edcSpk1
+c8:d5:fe:e6:a2:d8 1qaz2wsx3edcSpk2
+18:fe:34:db:59:72 1qaz2wsx3edcEsp
+d0:73:d5:12:8e:30 1qaz2wsx3edcLight1
+d0:73:d5:02:41:da 1qaz2wsx3edcLight2
+94:10:3e:36:60:09 1qaz2wsx3edc
index d4a09ead2081e8ab5fc3467a5f415424c03df5ab..15199a0047cc52b252c594c4156b60b4b519b7c7 100644 (file)
@@ -14,6 +14,7 @@ config wifi-iface 'default_radio0'
        option ssid 'LEDE'
        option encryption 'psk2'
        option key '1qaz2wsx3edc'
+       option wpa_psk_file '/etc/config/hostapd-psk'
        option isolate '1'
 
 config wifi-device 'radio1'
@@ -31,4 +32,5 @@ config wifi-iface 'default_radio1'
        option ssid 'LEDE'
        option encryption 'psk2'
        option key '1qaz2wsx3edc'
+       option wpa_psk_file '/etc/config/hostapd-psk'
        option isolate '1'
diff --git a/sentinel_setup/register/README b/sentinel_setup/register/README
new file mode 100644 (file)
index 0000000..129e2f3
--- /dev/null
@@ -0,0 +1,19 @@
+Device registration utility for Sentinel system
+This is a simple script that register a new device
+into /etc/config/dhcp and /etc/hostapd-psk
+Copyright (c) 2015-2017, Rahmadi Trimananda <rtrimana@uci.edu> PLRG@UCIrvine
+
+Usage:
+       ./register_device.sh [-h]
+       ./register_device.sh [-a <mac-address> <ip-address> <key> <device-name>]
+       ./register_device.sh [-l]
+
+Options:
+       -h      show this usage
+       -a      adding device by putting MAC address, desired IP address, key, and device name (optional)
+       -l      show list of devices registered
+
+
+Notes:
+- This simple script now only adds device information (no delete feature)
+- Meant to ease the setup process (mimicking production environment)
diff --git a/sentinel_setup/register/devices.dat b/sentinel_setup/register/devices.dat
new file mode 100644 (file)
index 0000000..ffea2e2
--- /dev/null
@@ -0,0 +1,2 @@
+12:32:34:45:56:67      192.168.2.123   mydevice
+12:32:34:45:56:67      192.168.2.123   mydevice
diff --git a/sentinel_setup/register/register_device.sh b/sentinel_setup/register/register_device.sh
new file mode 100755 (executable)
index 0000000..193381b
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# Print usage
+if [ "$#" -eq 0 ] || [ "$1" == "-h" ]; then
+       echo "Device registration utility for Sentinel system"
+       echo "This is a simple script that register a new device"
+       echo "into /etc/config/dhcp and /etc/hostapd-psk"
+       echo "Copyright (c) 2015-2017, Rahmadi Trimananda <rtrimana@uci.edu> PLRG@UCIrvine"
+       echo ""
+       echo "Usage:"
+       echo "  ./register_device.sh [-h]"
+       echo "  ./register_device.sh [-a <mac-address> <ip-address> <key> <device-name>]"
+       echo "  ./register_device.sh [-l]"
+       echo ""
+       echo "Options:"
+       echo "  -h      show this usage"
+       echo "  -a      adding device by putting MAC address, desired IP address, key, and device name (optional)"
+       echo "  -l      show list of devices registered"
+       echo ""
+
+elif [ "$1" == "-a" ]; then
+
+       if [ "$2" == "" ] || [ "$3" == "" ] || [ "$4" == "" ]; then
+               echo "Empty or incomplete parameters! Please run ./register_device.sh -h for usage."
+       else
+               # Add a new device
+               MAC=$2
+               IP=$3
+               KEY=$4
+
+               # Keep a local log
+               echo "$MAC      $IP     $KEY    $5" >> devices.dat
+
+               # Insert into /etc/hostapd-psk
+               echo "$MAC $KEY" >> /etc/hostapd-psk
+
+               # Insert into /etc/config/dhcp
+               echo "" >> /etc/config/dhcp
+               if [ "$5" != "" ]; then # If device-name is not empty
+                       echo "# $5" >> /etc/config/dhcp
+               fi
+               echo "config host" >> /etc/config/dhcp
+               echo "  option ip '$IP'" >> /etc/config/dhcp
+               echo "  option mac '$MAC'" >> /etc/config/dhcp
+
+               if [ "$5" != "" ]; then # If device-name is not empty
+                       echo "  option name '$5'" >> /etc/config/dhcp
+               fi
+               echo "Device added!"
+       fi
+                                                 
+elif [ "$1" == "-l" ]; then
+       # Print list of devices
+       echo "List of devices"
+       cat devices.dat
+       echo ""
+       echo "/etc/hostapd-psk"
+       cat /etc/hostapd-psk
+else
+       echo "Unknown option. Please run ./register_device.sh -h for usage."
+fi
+
diff --git a/sentinel_setup/setup/dhcp b/sentinel_setup/setup/dhcp
new file mode 100755 (executable)
index 0000000..2863248
--- /dev/null
@@ -0,0 +1 @@
+cat /tmp/dhcp.leases