Updated latest
This commit is contained in:
1 parent
092c16b615
commit
dabfa552ee
5 files changed
+83
-9
No files matched your search
@@ -30,10 +30,17 @@ hub:
|
||||
name: 'flic'
|
||||
cam:
|
||||
- name: 'korie'
|
||||
mac: '01:9c:8e:cd:25:83:1f'
|
||||
mac: '9C:8E:CD:25:83:1F'
|
||||
- name: 'eddie'
|
||||
mac: '01:a0:60:32:03:86:8a'
|
||||
mac: 'A0:60:32:03:86:8A'
|
||||
- name: 'doorbell'
|
||||
mac: '01:48:9e:9d:4a:32:80'
|
||||
mac: '48:9E:9D:4A:32:80'
|
||||
- name: 'livingroom'
|
||||
mac: '34:60:F9:D7:51:3F'
|
||||
mac: '34:60:F9:D7:51:3F'
|
||||
iot:
|
||||
- name: 'korieLamp'
|
||||
mac: '60:74:F4:4D:B8:C5'
|
||||
- name: 'officestrip'
|
||||
mac: 'DC:4F:22:24:0C:E4'
|
||||
- name: 'ecobee'
|
||||
mac: '44:61:32:FC:10:EC'
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
@@ -6,8 +7,10 @@ import yaml
|
||||
BASE_PATH = Path(__file__).parent
|
||||
CONFIG_FILE = BASE_PATH / "config.yaml"
|
||||
OUTPUT_FOLDER = BASE_PATH / "output"
|
||||
DNSMASQ_CONF = OUTPUT_FOLDER / "var" / "dnsmasq.conf"
|
||||
DNSMASQ_CONF = OUTPUT_FOLDER / "etc/dnsmasq.conf"
|
||||
SUMMARY = OUTPUT_FOLDER / "summary.yaml"
|
||||
|
||||
shutil.rmtree(OUTPUT_FOLDER)
|
||||
DNSMASQ_CONF.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
root_domain = "internal"
|
||||
@@ -16,6 +19,7 @@ ip_prefix_map = {
|
||||
"k3s": "10.0.11.",
|
||||
"hub": "10.0.12.",
|
||||
"cam": "10.0.13.",
|
||||
"iot": "10.0.14.",
|
||||
}
|
||||
|
||||
def cap1_and_join(*args: str) -> str:
|
||||
|
||||
+9
-3
@@ -30,11 +30,17 @@ address=/basement.home.sosnovsky.ca/10.0.12.2
|
||||
address=/.basement.home.sosnovsky.ca/10.0.12.2
|
||||
dhcp-host=4E:F6:9C:7C:56:33,HubFlic,10.0.12.3,infinite
|
||||
address=/flic.hub.internal/10.0.12.3
|
||||
dhcp-host=01:9c:8e:cd:25:83:1f,CamKorie,10.0.13.1,infinite
|
||||
dhcp-host=9C:8E:CD:25:83:1F,CamKorie,10.0.13.1,infinite
|
||||
address=/korie.cam.internal/10.0.13.1
|
||||
dhcp-host=01:a0:60:32:03:86:8a,CamEddie,10.0.13.2,infinite
|
||||
dhcp-host=A0:60:32:03:86:8A,CamEddie,10.0.13.2,infinite
|
||||
address=/eddie.cam.internal/10.0.13.2
|
||||
dhcp-host=01:48:9e:9d:4a:32:80,CamDoorbell,10.0.13.3,infinite
|
||||
dhcp-host=48:9E:9D:4A:32:80,CamDoorbell,10.0.13.3,infinite
|
||||
address=/doorbell.cam.internal/10.0.13.3
|
||||
dhcp-host=34:60:F9:D7:51:3F,CamLivingroom,10.0.13.4,infinite
|
||||
address=/livingroom.cam.internal/10.0.13.4
|
||||
dhcp-host=60:74:F4:4D:B8:C5,IotKorielamp,10.0.14.1,infinite
|
||||
address=/korieLamp.iot.internal/10.0.14.1
|
||||
dhcp-host=DC:4F:22:24:0C:E4,IotOfficestrip,10.0.14.2,infinite
|
||||
address=/officestrip.iot.internal/10.0.14.2
|
||||
dhcp-host=44:61:32:FC:10:EC,IotEcobee,10.0.14.3,infinite
|
||||
address=/ecobee.iot.internal/10.0.14.3
|
||||
@@ -52,4 +52,14 @@ Cam:
|
||||
host: "doorbell.cam.internal"
|
||||
Livingroom:
|
||||
ip: "10.0.13.4"
|
||||
host: "livingroom.cam.internal"
|
||||
host: "livingroom.cam.internal"
|
||||
Iot:
|
||||
Korielamp:
|
||||
ip: "10.0.14.1"
|
||||
host: "korieLamp.iot.internal"
|
||||
Officestrip:
|
||||
ip: "10.0.14.2"
|
||||
host: "officestrip.iot.internal"
|
||||
Ecobee:
|
||||
ip: "10.0.14.3"
|
||||
host: "ecobee.iot.internal"
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASE_PATH=$(realpath $BASH_SOURCE | xargs dirname)
|
||||
|
||||
ROUTER=${1:-10.0.0.1}
|
||||
USER=${2:-root}
|
||||
|
||||
function ask {
|
||||
q=${1:-"Are you sure"}
|
||||
echo
|
||||
read -p "$q? [Y/N]" -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
echo "Continuing..."
|
||||
else
|
||||
echo "Stopping!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
server=$USER@$ROUTER
|
||||
echo "using 🤖 $server"
|
||||
|
||||
pushd $BASE_PATH
|
||||
echo "Updating conf..."
|
||||
./gen-mappings.py
|
||||
cat output/summary.yaml
|
||||
ask
|
||||
|
||||
scp -O output/etc/dnsmasq.conf $USER@$ROUTER:/tmp/dnsmasq.new.conf
|
||||
ssh $USER@$ROUTER << EOF
|
||||
echo "Backing up dnsmasq.conf file to /tmp/dnsmasq.old.conf"
|
||||
cp /etc/dnsmasq.conf /tmp/dnsmasq.old.conf
|
||||
echo "Updating dnsmasq.conf 🙇🏼"
|
||||
cp /tmp/dnsmasq.new.conf /etc/dnsmasq.conf
|
||||
if dnsmasq --test ; then
|
||||
/etc/init.d/dnsmasq restart
|
||||
else
|
||||
echo "Updated Failed! 🚨"
|
||||
echo "Attempting to revert back..."
|
||||
cp /tmp/dnsmasq.old.conf /etc/dnsmasq.conf
|
||||
dnsmasq --test
|
||||
echo "Revert successful! 👍"
|
||||
fi
|
||||
EOF
|
||||
Reference in new issue
Block a user