From 1c2e75226d2e1aab0a3a68600611d089d6d9787d Mon Sep 17 00:00:00 2001 From: Ariel Sosnovsky Date: Fri, 9 Feb 2024 11:18:50 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Updated=20Router=20Config=20at?= =?UTF-8?q?=20Fri=20Feb=20=209=2011:18:49=20EST=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- os/routers/glmain/gen-mappings.py | 6 +-- os/routers/glmain/output/etc/dnsmasq.conf | 62 ----------------------- os/routers/glmain/output/etc/ethers | 4 -- os/routers/glmain/push.sh | 32 ++++++------ 4 files changed, 19 insertions(+), 85 deletions(-) diff --git a/os/routers/glmain/gen-mappings.py b/os/routers/glmain/gen-mappings.py index fa8cab8..0c8eb69 100755 --- a/os/routers/glmain/gen-mappings.py +++ b/os/routers/glmain/gen-mappings.py @@ -48,12 +48,12 @@ with DNSMASQ_CONF.open('w') as dfp, SUMMARY.open('w') as sfp, ETHERS.open('w') a host = f"{name}.{sub_domain}.{root_domain}" sfp.write(f'\n ip: "{ip}"') sfp.write(f'\n host: "{host}"') - dfp.write(f"dhcp-host={mac},{cap1_and_join(sub_domain, name)},{ip},infinite\n") - dfp.write(f"address=/{host}/{ip}\n") + # dfp.write(f"dhcp-host={mac},{cap1_and_join(sub_domain, name)},{ip},infinite\n") + # dfp.write(f"address=/{host}/{ip}\n") efp.write(f'{mac} {ip}\n') efp.write(f'{mac} {host}\n') if domain := dvc.get('domain'): dfp.write(f"address=/{domain}/{ip}\n") dfp.write(f"address=/.{domain}/{ip}\n") sfp.write(f'\n domain: "{domain}"') - efp.write(f'{mac} {domain}\n') \ No newline at end of file + # efp.write(f'{mac} {domain}\n') \ No newline at end of file diff --git a/os/routers/glmain/output/etc/dnsmasq.conf b/os/routers/glmain/output/etc/dnsmasq.conf index 1b85bdd..224301d 100644 --- a/os/routers/glmain/output/etc/dnsmasq.conf +++ b/os/routers/glmain/output/etc/dnsmasq.conf @@ -1,70 +1,8 @@ -dhcp-host=3C:7C:3F:1E:B7:A0,LabTnas1,10.0.10.1,infinite -address=/tnas1.lab.internal/10.0.10.1 address=/tnas1.lab.local/10.0.10.1 address=/.tnas1.lab.local/10.0.10.1 -dhcp-host=00:A0:98:3D:7C:C8,LabKubedb,10.0.10.2,infinite -address=/kubedb.lab.internal/10.0.10.2 -dhcp-host=B8:27:EB:F7:44:4E,LabPi1,10.0.10.3,infinite -address=/pi1.lab.internal/10.0.10.3 -dhcp-host=9C:BF:0D:00:56:51,LabFws1,10.0.10.4,infinite -address=/fws1.lab.internal/10.0.10.4 -dhcp-host=7C:83:34:B8:7B:43,K3sBee1,10.0.11.1,infinite -address=/bee1.k3s.internal/10.0.11.1 address=/home.sosnovsky.ca/10.0.11.1 address=/.home.sosnovsky.ca/10.0.11.1 -dhcp-host=68:1D:EF:26:B7:6C,K3sTerry1,10.0.11.2,infinite -address=/terry1.k3s.internal/10.0.11.2 -dhcp-host=58:47:CA:71:D8:E6,K3sMinisf1,10.0.11.3,infinite -address=/minisf1.k3s.internal/10.0.11.3 -dhcp-host=00:A0:98:17:B2:64,K3sTnas1,10.0.11.4,infinite -address=/tnas1.k3s.internal/10.0.11.4 -dhcp-host=E4:5F:01:A2:8D:BC,HubCastle,10.0.12.1,infinite -address=/castle.hub.internal/10.0.12.1 address=/castle.home.sosnovsky.ca/10.0.12.1 address=/.castle.home.sosnovsky.ca/10.0.12.1 -dhcp-host=DC:A6:32:92:B2:79,HubBasement,10.0.12.2,infinite -address=/basement.hub.internal/10.0.12.2 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=9C:8E:CD:25:83:1F,CamKorie,10.0.13.1,infinite -address=/korie.cam.internal/10.0.13.1 -dhcp-host=A0:60:32:03:86:8A,CamEddie,10.0.13.2,infinite -address=/eddie.cam.internal/10.0.13.2 -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,IotKorie-lamp,10.0.14.1,infinite -address=/korie-lamp.iot.internal/10.0.14.1 -dhcp-host=DC:4F:22:24:0C:E4,IotOffice-strip,10.0.14.2,infinite -address=/office-strip.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 -dhcp-host=30:30:F9:DC:A8:18,IotApollo-eddie,10.0.14.4,infinite -address=/apollo-eddie.iot.internal/10.0.14.4 -dhcp-host=30:30:F9:DA:C7:A4,IotApollo-office,10.0.14.5,infinite -address=/apollo-office.iot.internal/10.0.14.5 -dhcp-host=30:30:F9:DC:BE:7C,IotApollo-laundry,10.0.14.6,infinite -address=/apollo-laundry.iot.internal/10.0.14.6 -dhcp-host=64:B7:08:28:52:50,IotEpl-kitchen,10.0.14.7,infinite -address=/epl-kitchen.iot.internal/10.0.14.7 -dhcp-host=64:B7:08:28:56:F4,IotEpl-livingroom,10.0.14.8,infinite -address=/epl-livingroom.iot.internal/10.0.14.8 -dhcp-host=B8:D6:1A:8A:5F:F4,IotShelly-basement-living,10.0.14.9,infinite -address=/shelly-basement-living.iot.internal/10.0.14.9 -dhcp-host=B8:D6:1A:8C:4C:DC,IotShelly-basement-shared,10.0.14.10,infinite -address=/shelly-basement-shared.iot.internal/10.0.14.10 -dhcp-host=C8:2B:96:1D:DA:B4,IotShelly-laundry-light,10.0.14.11,infinite -address=/shelly-laundry-light.iot.internal/10.0.14.11 -dhcp-host=48:9E:BD:CB:07:E3,AplHp-print,10.0.15.1,infinite -address=/hp-print.apl.internal/10.0.15.1 -dhcp-host=20:DF:B9:71:55:9C,AplGm-eddie,10.0.15.2,infinite -address=/gm-eddie.apl.internal/10.0.15.2 -dhcp-host=CC:6A:10:8B:7D:D3,AplMyq-garage,10.0.15.3,infinite -address=/myq-garage.apl.internal/10.0.15.3 -dhcp-host=04:99:B9:86:2D:AE,AplPod-korie,10.0.15.4,infinite -address=/pod-korie.apl.internal/10.0.15.4 -dhcp-host=04:99:B9:88:ED:3B,AplPod-livingroom,10.0.15.5,infinite -address=/pod-livingroom.apl.internal/10.0.15.5 diff --git a/os/routers/glmain/output/etc/ethers b/os/routers/glmain/output/etc/ethers index 820094d..ba3bf55 100644 --- a/os/routers/glmain/output/etc/ethers +++ b/os/routers/glmain/output/etc/ethers @@ -1,7 +1,6 @@ #Lab 3C:7C:3F:1E:B7:A0 10.0.10.1 3C:7C:3F:1E:B7:A0 tnas1.lab.internal -3C:7C:3F:1E:B7:A0 tnas1.lab.local 00:A0:98:3D:7C:C8 10.0.10.2 00:A0:98:3D:7C:C8 kubedb.lab.internal B8:27:EB:F7:44:4E 10.0.10.3 @@ -11,7 +10,6 @@ B8:27:EB:F7:44:4E pi1.lab.internal #K3s 7C:83:34:B8:7B:43 10.0.11.1 7C:83:34:B8:7B:43 bee1.k3s.internal -7C:83:34:B8:7B:43 home.sosnovsky.ca 68:1D:EF:26:B7:6C 10.0.11.2 68:1D:EF:26:B7:6C terry1.k3s.internal 58:47:CA:71:D8:E6 10.0.11.3 @@ -21,10 +19,8 @@ B8:27:EB:F7:44:4E pi1.lab.internal #Hub E4:5F:01:A2:8D:BC 10.0.12.1 E4:5F:01:A2:8D:BC castle.hub.internal -E4:5F:01:A2:8D:BC castle.home.sosnovsky.ca DC:A6:32:92:B2:79 10.0.12.2 DC:A6:32:92:B2:79 basement.hub.internal -DC:A6:32:92:B2:79 basement.home.sosnovsky.ca 4E:F6:9C:7C:56:33 10.0.12.3 4E:F6:9C:7C:56:33 flic.hub.internal #Cam diff --git a/os/routers/glmain/push.sh b/os/routers/glmain/push.sh index 2ab5c62..34305ed 100755 --- a/os/routers/glmain/push.sh +++ b/os/routers/glmain/push.sh @@ -30,23 +30,23 @@ echo "Updating conf..." cat output/summary.yaml ask "continue update" -# scp -O output/etc/dnsmasq.conf "$server:/tmp/dnsmasq.new.conf" +scp -O output/etc/dnsmasq.conf "$server:/tmp/dnsmasq.new.conf" scp -O output/etc/ethers "$server:/etc/ethers" -# ssh "$server" << 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 +ssh "$server" << 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 git add . git commit -m "🤖 Updated Router Config at $(date)"