Merge branch 'stable' of github.com:asosnovsky/homelab into stable
This commit is contained in:
commit
8a00bc275f
44 files changed
+804
-830
No files matched your search
+2
-1
@@ -18,9 +18,10 @@
|
||||
services.nfs.server.enable = true;
|
||||
services.rpcbind.enable = true;
|
||||
environment.systemPackages = with pkgs; [
|
||||
pkgs.k3s
|
||||
k3s
|
||||
nfs-utils
|
||||
git
|
||||
|
||||
];
|
||||
services.k3s.enable = true;
|
||||
services.k3s.role = "server";
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
function update-os {
|
||||
update_os() {
|
||||
# Updating
|
||||
sudo apt-get update -y
|
||||
sudo apt-get upgrade -y
|
||||
}
|
||||
|
||||
function remove-bad-package {
|
||||
remove_bad_package() {
|
||||
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
|
||||
sudo apt autoremove -y
|
||||
}
|
||||
|
||||
function instsall-core-package {
|
||||
instsall_core_package() {
|
||||
sudo apt install -y \
|
||||
git \
|
||||
jq \
|
||||
@@ -19,7 +19,7 @@ function instsall-core-package {
|
||||
sh <(curl -L https://nixos.org/nix/install) --daemon
|
||||
}
|
||||
|
||||
function install-docker {
|
||||
install_docker() {
|
||||
echo "Add Docker's official GPG key..."
|
||||
sudo apt-get install ca-certificates curl gnupg
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
@@ -42,45 +42,44 @@ function install-docker {
|
||||
docker-compose-plugin
|
||||
}
|
||||
|
||||
function install-docker-compose-systemd {
|
||||
install_docker_compose_systemd() {
|
||||
sudo mkdir -p /etc/docker/compose/
|
||||
sudo cp systemd/docker-compose@.service /etc/systemd/system/docker-compose@.service
|
||||
}
|
||||
|
||||
function mount-nfs-torrents {
|
||||
mount_nfs_torrents() {
|
||||
sudo cp /etc/fstab /etc/fstab.backup
|
||||
sudo mkdir -p /torrents
|
||||
sudo echo "truenas.local:/mnt/EightTerra/DownloadedTorrents /torrents/ nfs auto 0 0" | sudo tee -a /etc/fstab
|
||||
sudo mount -a
|
||||
}
|
||||
|
||||
function install-qbittorrent {
|
||||
install_qbittorrent() {
|
||||
sudo useradd -r -m qbittorrent
|
||||
sudo usermod -a -G qbittorrent $USER
|
||||
sudo usermod -a -G qbittorrent "$USER"
|
||||
sudo apt install -y qbittorrent-nox
|
||||
sudo cp systemd/qbittorrent.service /etc/systemd/system/qbittorrent.service
|
||||
sudo systemctl start qbittorrent
|
||||
sudo systemctl enable qbittorrent
|
||||
}
|
||||
|
||||
function install-speedtest-cli {
|
||||
mkdir -p $HOME/.local/bin
|
||||
mkdir -p $HOME/tmp/speedtest
|
||||
pushd $HOME/tmp/speedtest/
|
||||
install_speedtest_cli() {
|
||||
mkdir -p "$HOME"/.local/bin
|
||||
mkdir -p "$HOME"/tmp/speedtest
|
||||
pushd "$HOME"/tmp/speedtest/ || exit 1
|
||||
wget https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_linux_armv7.tar.gz
|
||||
tar -xvf librespeed-cli_1.0.10_linux_armv7.tar.gz
|
||||
cp librespeed-cli $HOME/.local/bin/speedtest-cli
|
||||
popd
|
||||
rm -rf $HOME/tmp/speedtest
|
||||
cp librespeed-cli "$HOME"/.local/bin/speedtest-cli
|
||||
rm -rf "$HOME"/tmp/speedtest
|
||||
}
|
||||
|
||||
|
||||
function install-transmission {
|
||||
install_transmission() {
|
||||
sudo apt-get install transmission-daemon
|
||||
sudo ufw allow 9091,51413/tcp
|
||||
}
|
||||
|
||||
function set-static-ip() {
|
||||
set_static_ip() {
|
||||
ip=${1}
|
||||
intf=${2:-eth0}
|
||||
routerip=${3:-192.168.8.1}
|
||||
@@ -91,4 +90,9 @@ static_routers=$routerip
|
||||
static ip_address=$ip/24
|
||||
# <---- AUTOGENERATED --->
|
||||
" | tee -a /etc/dhcpcd.conf
|
||||
}
|
||||
|
||||
install_openvpn() {
|
||||
sudo apt install openvpn
|
||||
sudo cp systemd/openvpn-client.service /etc/systemd/system/openvpn-client.service
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=OpenVPN Client
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/etc/openvpn
|
||||
EnvironmentFile=/etc/openvpn/openvpn.service.env
|
||||
ExecStart=/usr/sbin/openvpn \
|
||||
--config "${CONFIG_FILE}" \
|
||||
--auth-user-pass "${AUTH_FILE}"
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,6 +1,7 @@
|
||||
lab:
|
||||
- mac: '3C:7C:3F:1E:B7:A0'
|
||||
name: 'tnas1'
|
||||
domain: 'tnas1.lab.local'
|
||||
- mac: '00:A0:98:3D:7C:C8'
|
||||
name: 'kubedb'
|
||||
- mac: 'B8:27:EB:F7:44:4E'
|
||||
@@ -13,10 +14,10 @@ k3s:
|
||||
domain: home.sosnovsky.ca
|
||||
- mac: '68:1D:EF:26:B7:6C'
|
||||
name: 'terry1'
|
||||
domain: home.sosnovsky.ca
|
||||
# domain: home.sosnovsky.ca
|
||||
- mac: '58:47:CA:71:D8:E6'
|
||||
name: 'minisf1'
|
||||
domain: home.sosnovsky.ca
|
||||
# domain: home.sosnovsky.ca
|
||||
- mac: '00:A0:98:17:B2:64'
|
||||
name: 'tnas1'
|
||||
hub:
|
||||
@@ -37,6 +38,8 @@ cam:
|
||||
mac: '48:9E:9D:4A:32:80'
|
||||
- name: 'livingroom'
|
||||
mac: '34:60:F9:D7:51:3F'
|
||||
- name: 'garage'
|
||||
mac: ''
|
||||
iot:
|
||||
- name: 'korie-lamp'
|
||||
mac: '60:74:F4:4D:B8:C5'
|
||||
@@ -47,4 +50,59 @@ iot:
|
||||
- name: 'apollo-eddie'
|
||||
mac: '30:30:F9:DC:A8:18'
|
||||
- name: 'apollo-office'
|
||||
mac: '30:30:F9:DA:C7:A4'
|
||||
mac: '30:30:F9:DA:C7:A4'
|
||||
- name: 'apollo-laundry'
|
||||
mac: '30:30:F9:DC:BE:7C'
|
||||
- name: 'epl-kitchen'
|
||||
mac: '64:B7:08:28:52:50'
|
||||
- name: 'epl-livingroom'
|
||||
mac: '64:B7:08:28:56:F4'
|
||||
- name: 'shelly-basement-living'
|
||||
mac: 'B8:D6:1A:8A:5F:F4'
|
||||
- name: 'shelly-basement-shared'
|
||||
mac: 'B8:D6:1A:8C:4C:DC'
|
||||
- name: 'shelly-laundry-light'
|
||||
mac: 'C8:2B:96:1D:DA:B4'
|
||||
apl:
|
||||
- name: 'hp-print'
|
||||
mac: '48:9E:BD:CB:07:E3'
|
||||
- name: 'gm-eddie'
|
||||
mac: '20:DF:B9:71:55:9C'
|
||||
justMac: true
|
||||
- name: 'myq-garage'
|
||||
mac: 'CC:6A:10:8B:7D:D3'
|
||||
- name: 'pod-korie'
|
||||
mac: '04:99:B9:86:2D:AE'
|
||||
justMac: true
|
||||
- name: 'pod-livingroom'
|
||||
mac: '04:99:B9:88:ED:3B'
|
||||
justMac: true
|
||||
- name: 'appletv-livingroom'
|
||||
mac: '48:E1:5C:5B:CB:A3'
|
||||
- name: 'samsuntv-livingroom'
|
||||
mac: 'F0:70:4F:54:F3:F0'
|
||||
- name: 'leviot-humid1'
|
||||
mac: '3C:E9:0E:62:14:D8'
|
||||
justMac: true
|
||||
- name: 'leviot-humid2'
|
||||
mac: '1C:9D:C2:39:61:F8'
|
||||
justMac: true
|
||||
- name: 'amzn-bedroom'
|
||||
mac: 'D8:BE:65:F2:ED:18'
|
||||
justMac: true
|
||||
router:
|
||||
- name: 'gl-basement'
|
||||
mac: '94:83:C4:31:D5:CE'
|
||||
- name: 'velica-main'
|
||||
mac: '94:83:C4:41:77:BA'
|
||||
- name: 'velica-node1'
|
||||
mac: '94:83:C4:41:77:29'
|
||||
devices:
|
||||
- name: 'fwlaptop'
|
||||
mac: '14:AC:60:29:85:4D'
|
||||
- name: 'sumomac'
|
||||
mac: 'F8:E4:3B:36:0F:E4'
|
||||
- name: 'steamdeck'
|
||||
mac: '34:6F:24:CA:70:57'
|
||||
- name: 'vitapc'
|
||||
mac: 'E0:0A:F6:79:C6:E9'
|
||||
@@ -8,10 +8,12 @@ BASE_PATH = Path(__file__).parent
|
||||
CONFIG_FILE = BASE_PATH / "config.yaml"
|
||||
OUTPUT_FOLDER = BASE_PATH / "output"
|
||||
DNSMASQ_CONF = OUTPUT_FOLDER / "etc/dnsmasq.conf"
|
||||
ETHERS = OUTPUT_FOLDER / "etc/ethers"
|
||||
SUMMARY = OUTPUT_FOLDER / "summary.yaml"
|
||||
|
||||
shutil.rmtree(OUTPUT_FOLDER)
|
||||
DNSMASQ_CONF.parent.mkdir(exist_ok=True, parents=True)
|
||||
ETHERS.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
root_domain = "internal"
|
||||
ip_prefix_map = {
|
||||
@@ -20,6 +22,14 @@ ip_prefix_map = {
|
||||
"hub": "10.0.12.",
|
||||
"cam": "10.0.13.",
|
||||
"iot": "10.0.14.",
|
||||
"apl": "10.0.15.",
|
||||
"router": "10.0.16.",
|
||||
"devices": "10.0.0.",
|
||||
}
|
||||
defaults = {
|
||||
'devices': {
|
||||
'justMac': True,
|
||||
}
|
||||
}
|
||||
|
||||
def cap1_and_join(*args: str) -> str:
|
||||
@@ -32,21 +42,28 @@ def cap1_and_join(*args: str) -> str:
|
||||
with CONFIG_FILE.open('r') as fp:
|
||||
devices = yaml.safe_load(fp)
|
||||
|
||||
with DNSMASQ_CONF.open('w') as dfp, SUMMARY.open('w') as sfp:
|
||||
with DNSMASQ_CONF.open('w') as dfp, SUMMARY.open('w') as sfp, ETHERS.open('w') as efp:
|
||||
for sub_domain, configs in devices.items():
|
||||
default_values = defaults.get(sub_domain, {})
|
||||
ip_prefix = ip_prefix_map[sub_domain]
|
||||
sfp.write(f'\n{cap1_and_join(sub_domain)}:')
|
||||
for ip_suffix, dvc in enumerate(configs, start=1):
|
||||
efp.write(f'#{cap1_and_join(sub_domain)}\n')
|
||||
ip_suffix = 0
|
||||
for dvc in configs:
|
||||
ip_suffix += 1
|
||||
dvc = {**default_values, **dvc}
|
||||
mac = dvc['mac']
|
||||
name = dvc['name']
|
||||
sfp.write(f'\n {cap1_and_join(name)}:')
|
||||
ip = f"{ip_prefix}{ip_suffix}"
|
||||
host = f"{name}.{sub_domain}.{root_domain}"
|
||||
sfp.write(f'\n ip: "{ip}"')
|
||||
if not dvc.get('justMac', False):
|
||||
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")
|
||||
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}"')
|
||||
if not dvc.get('justMac', False):
|
||||
efp.write(f'{mac} {ip}\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} {host}\n')
|
||||
@@ -1,50 +1,8 @@
|
||||
dhcp-host=3C:7C:3F:1E:B7:A0,LabTnas1,10.0.10.1,infinite
|
||||
address=/tnas1.lab.internal/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=/tnas1.lab.local/10.0.10.1
|
||||
address=/.tnas1.lab.local/10.0.10.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
|
||||
address=/home.sosnovsky.ca/10.0.11.2
|
||||
address=/.home.sosnovsky.ca/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
|
||||
address=/home.sosnovsky.ca/10.0.11.3
|
||||
address=/.home.sosnovsky.ca/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
|
||||
@@ -0,0 +1,86 @@
|
||||
#Lab
|
||||
3C:7C:3F:1E:B7:A0 10.0.10.1
|
||||
3C:7C:3F:1E:B7:A0 tnas1.lab.internal
|
||||
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
|
||||
B8:27:EB:F7:44:4E pi1.lab.internal
|
||||
9C:BF:0D:00:56:51 10.0.10.4
|
||||
9C:BF:0D:00:56:51 fws1.lab.internal
|
||||
#K3s
|
||||
7C:83:34:B8:7B:43 10.0.11.1
|
||||
7C:83:34:B8:7B:43 bee1.k3s.internal
|
||||
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
|
||||
58:47:CA:71:D8:E6 minisf1.k3s.internal
|
||||
00:A0:98:17:B2:64 10.0.11.4
|
||||
00:A0:98:17:B2:64 tnas1.k3s.internal
|
||||
#Hub
|
||||
E4:5F:01:A2:8D:BC 10.0.12.1
|
||||
E4:5F:01:A2:8D:BC castle.hub.internal
|
||||
DC:A6:32:92:B2:79 10.0.12.2
|
||||
DC:A6:32:92:B2:79 basement.hub.internal
|
||||
4E:F6:9C:7C:56:33 10.0.12.3
|
||||
4E:F6:9C:7C:56:33 flic.hub.internal
|
||||
#Cam
|
||||
9C:8E:CD:25:83:1F 10.0.13.1
|
||||
9C:8E:CD:25:83:1F korie.cam.internal
|
||||
A0:60:32:03:86:8A 10.0.13.2
|
||||
A0:60:32:03:86:8A eddie.cam.internal
|
||||
48:9E:9D:4A:32:80 10.0.13.3
|
||||
48:9E:9D:4A:32:80 doorbell.cam.internal
|
||||
34:60:F9:D7:51:3F 10.0.13.4
|
||||
34:60:F9:D7:51:3F livingroom.cam.internal
|
||||
10.0.13.5
|
||||
garage.cam.internal
|
||||
#Iot
|
||||
60:74:F4:4D:B8:C5 10.0.14.1
|
||||
60:74:F4:4D:B8:C5 korie-lamp.iot.internal
|
||||
DC:4F:22:24:0C:E4 10.0.14.2
|
||||
DC:4F:22:24:0C:E4 office-strip.iot.internal
|
||||
44:61:32:FC:10:EC 10.0.14.3
|
||||
44:61:32:FC:10:EC ecobee.iot.internal
|
||||
30:30:F9:DC:A8:18 10.0.14.4
|
||||
30:30:F9:DC:A8:18 apollo-eddie.iot.internal
|
||||
30:30:F9:DA:C7:A4 10.0.14.5
|
||||
30:30:F9:DA:C7:A4 apollo-office.iot.internal
|
||||
30:30:F9:DC:BE:7C 10.0.14.6
|
||||
30:30:F9:DC:BE:7C apollo-laundry.iot.internal
|
||||
64:B7:08:28:52:50 10.0.14.7
|
||||
64:B7:08:28:52:50 epl-kitchen.iot.internal
|
||||
64:B7:08:28:56:F4 10.0.14.8
|
||||
64:B7:08:28:56:F4 epl-livingroom.iot.internal
|
||||
B8:D6:1A:8A:5F:F4 10.0.14.9
|
||||
B8:D6:1A:8A:5F:F4 shelly-basement-living.iot.internal
|
||||
B8:D6:1A:8C:4C:DC 10.0.14.10
|
||||
B8:D6:1A:8C:4C:DC shelly-basement-shared.iot.internal
|
||||
C8:2B:96:1D:DA:B4 10.0.14.11
|
||||
C8:2B:96:1D:DA:B4 shelly-laundry-light.iot.internal
|
||||
#Apl
|
||||
48:9E:BD:CB:07:E3 10.0.15.1
|
||||
48:9E:BD:CB:07:E3 hp-print.apl.internal
|
||||
20:DF:B9:71:55:9C gm-eddie.apl.internal
|
||||
CC:6A:10:8B:7D:D3 10.0.15.3
|
||||
CC:6A:10:8B:7D:D3 myq-garage.apl.internal
|
||||
04:99:B9:86:2D:AE pod-korie.apl.internal
|
||||
04:99:B9:88:ED:3B pod-livingroom.apl.internal
|
||||
48:E1:5C:5B:CB:A3 10.0.15.6
|
||||
48:E1:5C:5B:CB:A3 appletv-livingroom.apl.internal
|
||||
F0:70:4F:54:F3:F0 10.0.15.7
|
||||
F0:70:4F:54:F3:F0 samsuntv-livingroom.apl.internal
|
||||
3C:E9:0E:62:14:D8 leviot-humid1.apl.internal
|
||||
1C:9D:C2:39:61:F8 leviot-humid2.apl.internal
|
||||
D8:BE:65:F2:ED:18 amzn-bedroom.apl.internal
|
||||
#Router
|
||||
94:83:C4:31:D5:CE 10.0.16.1
|
||||
94:83:C4:31:D5:CE gl-basement.router.internal
|
||||
94:83:C4:41:77:BA 10.0.16.2
|
||||
94:83:C4:41:77:BA velica-main.router.internal
|
||||
94:83:C4:41:77:29 10.0.16.3
|
||||
94:83:C4:41:77:29 velica-node1.router.internal
|
||||
#Devices
|
||||
14:AC:60:29:85:4D fwlaptop.devices.internal
|
||||
F8:E4:3B:36:0F:E4 sumomac.devices.internal
|
||||
34:6F:24:CA:70:57 steamdeck.devices.internal
|
||||
E0:0A:F6:79:C6:E9 vitapc.devices.internal
|
||||
@@ -3,6 +3,7 @@ Lab:
|
||||
Tnas1:
|
||||
ip: "10.0.10.1"
|
||||
host: "tnas1.lab.internal"
|
||||
domain: "tnas1.lab.local"
|
||||
Kubedb:
|
||||
ip: "10.0.10.2"
|
||||
host: "kubedb.lab.internal"
|
||||
@@ -20,11 +21,9 @@ K3s:
|
||||
Terry1:
|
||||
ip: "10.0.11.2"
|
||||
host: "terry1.k3s.internal"
|
||||
domain: "home.sosnovsky.ca"
|
||||
Minisf1:
|
||||
ip: "10.0.11.3"
|
||||
host: "minisf1.k3s.internal"
|
||||
domain: "home.sosnovsky.ca"
|
||||
Tnas1:
|
||||
ip: "10.0.11.4"
|
||||
host: "tnas1.k3s.internal"
|
||||
@@ -53,6 +52,9 @@ Cam:
|
||||
Livingroom:
|
||||
ip: "10.0.13.4"
|
||||
host: "livingroom.cam.internal"
|
||||
Garage:
|
||||
ip: "10.0.13.5"
|
||||
host: "garage.cam.internal"
|
||||
Iot:
|
||||
Korie-lamp:
|
||||
ip: "10.0.14.1"
|
||||
@@ -68,4 +70,66 @@ Iot:
|
||||
host: "apollo-eddie.iot.internal"
|
||||
Apollo-office:
|
||||
ip: "10.0.14.5"
|
||||
host: "apollo-office.iot.internal"
|
||||
host: "apollo-office.iot.internal"
|
||||
Apollo-laundry:
|
||||
ip: "10.0.14.6"
|
||||
host: "apollo-laundry.iot.internal"
|
||||
Epl-kitchen:
|
||||
ip: "10.0.14.7"
|
||||
host: "epl-kitchen.iot.internal"
|
||||
Epl-livingroom:
|
||||
ip: "10.0.14.8"
|
||||
host: "epl-livingroom.iot.internal"
|
||||
Shelly-basement-living:
|
||||
ip: "10.0.14.9"
|
||||
host: "shelly-basement-living.iot.internal"
|
||||
Shelly-basement-shared:
|
||||
ip: "10.0.14.10"
|
||||
host: "shelly-basement-shared.iot.internal"
|
||||
Shelly-laundry-light:
|
||||
ip: "10.0.14.11"
|
||||
host: "shelly-laundry-light.iot.internal"
|
||||
Apl:
|
||||
Hp-print:
|
||||
ip: "10.0.15.1"
|
||||
host: "hp-print.apl.internal"
|
||||
Gm-eddie:
|
||||
host: "gm-eddie.apl.internal"
|
||||
Myq-garage:
|
||||
ip: "10.0.15.3"
|
||||
host: "myq-garage.apl.internal"
|
||||
Pod-korie:
|
||||
host: "pod-korie.apl.internal"
|
||||
Pod-livingroom:
|
||||
host: "pod-livingroom.apl.internal"
|
||||
Appletv-livingroom:
|
||||
ip: "10.0.15.6"
|
||||
host: "appletv-livingroom.apl.internal"
|
||||
Samsuntv-livingroom:
|
||||
ip: "10.0.15.7"
|
||||
host: "samsuntv-livingroom.apl.internal"
|
||||
Leviot-humid1:
|
||||
host: "leviot-humid1.apl.internal"
|
||||
Leviot-humid2:
|
||||
host: "leviot-humid2.apl.internal"
|
||||
Amzn-bedroom:
|
||||
host: "amzn-bedroom.apl.internal"
|
||||
Router:
|
||||
Gl-basement:
|
||||
ip: "10.0.16.1"
|
||||
host: "gl-basement.router.internal"
|
||||
Velica-main:
|
||||
ip: "10.0.16.2"
|
||||
host: "velica-main.router.internal"
|
||||
Velica-node1:
|
||||
ip: "10.0.16.3"
|
||||
host: "velica-node1.router.internal"
|
||||
Devices:
|
||||
Fwlaptop:
|
||||
host: "fwlaptop.devices.internal"
|
||||
Sumomac:
|
||||
host: "sumomac.devices.internal"
|
||||
Steamdeck:
|
||||
host: "steamdeck.devices.internal"
|
||||
Vitapc:
|
||||
host: "vitapc.devices.internal"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASE_PATH=$(realpath $BASH_SOURCE | xargs dirname)
|
||||
BASE_PATH=$(realpath "${BASH_SOURCE[0]}" | xargs dirname)
|
||||
|
||||
ROUTER=${1:-10.0.0.1}
|
||||
USER=${2:-root}
|
||||
@@ -21,19 +21,21 @@ function ask {
|
||||
|
||||
|
||||
server=$USER@$ROUTER
|
||||
pushd "$BASE_PATH" || exit 1
|
||||
echo "using 🤖 $server"
|
||||
ask "continue update"
|
||||
|
||||
pushd $BASE_PATH
|
||||
echo "Updating conf..."
|
||||
./gen-mappings.py
|
||||
cat output/summary.yaml
|
||||
ask
|
||||
ask "continue update"
|
||||
|
||||
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"
|
||||
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 🙇🏼"
|
||||
echo 'Updating dnsmasq.conf 🙇🏼'
|
||||
cp /tmp/dnsmasq.new.conf /etc/dnsmasq.conf
|
||||
if dnsmasq --test ; then
|
||||
/etc/init.d/dnsmasq restart
|
||||
@@ -44,4 +46,8 @@ else
|
||||
dnsmasq --test
|
||||
echo "Revert successful! 👍"
|
||||
fi
|
||||
EOF
|
||||
EOF
|
||||
|
||||
git add .
|
||||
git commit -m "🤖 Updated Router Config at $(date)"
|
||||
git push
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
BASE_PATH=$(realpath "${BASH_SOURCE[0]}" | xargs dirname)
|
||||
|
||||
pushd "$BASE_PATH"
|
||||
|
||||
mode=${1:-"main"}
|
||||
host=${2:-"root@192.168.1.1"}
|
||||
file_name="create-${mode}.sh"
|
||||
dotenv_file_name=".env"
|
||||
|
||||
|
||||
if [ ! -f "${file_name}" ]; then
|
||||
echo "Invalid Mode ${mode}!"
|
||||
echo "Please use 'main' or 'ap'"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "${dotenv_file_name}" ]; then
|
||||
echo "Missing dotenv file!"
|
||||
echo "Please create a ${dotenv_file_name} in $BASE_PATH!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "mode=${mode}"
|
||||
echo "host=${host}"
|
||||
|
||||
read -p "Continue? [Y/N]" -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
echo "Continuing..."
|
||||
else
|
||||
echo "Stopping!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
scp -O "$file_name" "$host:/tmp/update-script.sh"
|
||||
scp -O "$dotenv_file_name" "$host:/tmp/.env"
|
||||
ssh -t "$host" <<EOF
|
||||
set -e
|
||||
echo "chmod +x /tmp/update-script.sh"
|
||||
chmod +x /tmp/update-script.sh
|
||||
echo "export \$(cat /tmp/.env | xargs -0)"
|
||||
export \$(cat /tmp/.env | xargs -0)
|
||||
echo "/tmp/update-script.sh"
|
||||
/tmp/update-script.sh
|
||||
EOF
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
opkg update --no-check-certificate
|
||||
opkg remove wpad-basic-*
|
||||
opkg install --force-overwrite \
|
||||
--no-check-certificate \
|
||||
wpad-openssl
|
||||
uci set system.@system[0].hostname="${HOSTNAME}"
|
||||
uci commit
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
HOSTNAME=${1:-$HOSTNAME}
|
||||
|
||||
echo "Configuring AP to $HOSTNAME"
|
||||
|
||||
n=5
|
||||
while [ "$n" -gt 0 ]; do
|
||||
echo "Starting in $n..."
|
||||
sleep 1
|
||||
n=$(( n - 1 ))
|
||||
done
|
||||
|
||||
for i in firewall dnsmasq odhcpd; do
|
||||
if /etc/init.d/"$i" enabled; then
|
||||
/etc/init.d/"$i" disable
|
||||
/etc/init.d/"$i" stop
|
||||
fi
|
||||
done
|
||||
|
||||
uci set network.lan.proto='dhcp'
|
||||
uci delete network.wan
|
||||
uci delete network.wan6
|
||||
uci delete network.lan.ipaddr
|
||||
uci delete network.lan.netmask
|
||||
|
||||
mv /etc/config/firewall /etc/config/firewall.unused
|
||||
|
||||
reboot
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# Turn an OpenWrt dumb access point into a Wi-fi mesh point
|
||||
|
||||
# ######################
|
||||
# you may customize this
|
||||
# ######################
|
||||
|
||||
MESH_NAME="kososvsky-mesh"
|
||||
MESH_RADIO=radio0
|
||||
MESH_CHANNEL=1
|
||||
|
||||
WIFI_NAME="kososvsky-main"
|
||||
WIFI_RADIO=radio1
|
||||
WIFI_CHANNEL=36
|
||||
WIFI_MOBDOMAIN='3333'
|
||||
|
||||
|
||||
if [ -z ${MESH_PWD} ]; then
|
||||
echo "Missing 'MESH_PWD'"
|
||||
exit 1
|
||||
else
|
||||
echo "MESH_NAME = ${MESH_NAME}"
|
||||
echo "MESH_PWD = ${MESH_PWD}"
|
||||
fi
|
||||
if [ -z ${WIFI_PWD} ]; then
|
||||
echo "Missing 'WIFI_PWD'"
|
||||
exit 1
|
||||
else
|
||||
echo "WIFI_NAME = ${WIFI_NAME}"
|
||||
echo "WIFI_PWD = ${WIFI_PWD}"
|
||||
fi
|
||||
|
||||
n=5
|
||||
while [ "$n" -gt 0 ]; do
|
||||
echo "Starting in $n..."
|
||||
sleep 1
|
||||
n=$(( n - 1 ))
|
||||
done
|
||||
|
||||
# install the wpad mesh package
|
||||
opkg update
|
||||
opkg install --force-overwrite wpad-mesh-openssl
|
||||
|
||||
# delete the "OpenWrt" radios
|
||||
uci delete wireless.default_radio0
|
||||
uci delete wireless.default_radio1
|
||||
|
||||
# create the mesh Wifi
|
||||
uci set wireless.wifinet0=wifi-iface
|
||||
uci set wireless.wifinet0.device="$MESH_RADIO"
|
||||
uci set wireless.wifinet0.mode='mesh'
|
||||
uci set wireless.wifinet0.encryption='sae'
|
||||
uci set wireless.wifinet0.mesh_id="$MESH_NAME"
|
||||
uci set wireless.wifinet0.mesh_fwding='1'
|
||||
uci set wireless.wifinet0.mesh_rssi_threshold='0'
|
||||
uci set wireless.wifinet0.key="$MESH_PWD"
|
||||
uci set wireless.wifinet0.network='lan'
|
||||
uci set "wireless.$MESH_RADIO.channel=$MESH_CHANNEL"
|
||||
uci delete "wireless.$MESH_RADIO.disabled"
|
||||
|
||||
# create the AP Wifi
|
||||
uci set wireless.wifinet1=wifi-iface
|
||||
uci set wireless.wifinet1.device=$WIFI_RADIO
|
||||
uci set wireless.wifinet1.mode='ap'
|
||||
uci set wireless.wifinet1.ssid=$WIFI_NAME
|
||||
uci set wireless.wifinet1.encryption='psk2'
|
||||
uci set wireless.wifinet1.key=$WIFI_PWD
|
||||
uci set wireless.wifinet1.ieee80211r='1'
|
||||
uci set wireless.wifinet1.mobility_domain=$WIFI_MOBDOMAIN
|
||||
uci set wireless.wifinet1.ft_over_ds='0'
|
||||
uci set wireless.wifinet1.ft_psk_generate_local='1'
|
||||
uci set wireless.wifinet1.network='lan'
|
||||
uci set "wireless.$WIFI_RADIO.channel"=$WIFI_CHANNEL
|
||||
uci delete "wireless.$WIFI_RADIO.disabled"
|
||||
|
||||
uci commit
|
||||
|
||||
wifi down
|
||||
/etc/init.d/wpad restart
|
||||
wifi up
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
MESH_PWD=$(echo "$MESH_PWD" | tr -d '"')
|
||||
WIFI_PWD=$(echo "$WIFI_PWD" | tr -d '"')
|
||||
output_file=${1:-"/etc/config/wireless"}
|
||||
|
||||
echo "writing to $output_file"
|
||||
|
||||
cat << EOF >> "$output_file"
|
||||
|
||||
config wifi-iface 'mesh'
|
||||
option device 'radio0'
|
||||
option disabled '0'
|
||||
option mode 'mesh'
|
||||
option ifname 'mesh0'
|
||||
option network 'lan'
|
||||
option mesh_id 'kosovsky-mesh'
|
||||
option encryption 'sae'
|
||||
option key '${MESH_PWD}'
|
||||
option mesh_fwding '1'
|
||||
option mesh_rssi_threshold '0'
|
||||
|
||||
config wifi-iface 'wifi5g'
|
||||
option ssid 'kosovsky-main'
|
||||
option disabled '0'
|
||||
option device 'radio2'
|
||||
option mode 'ap'
|
||||
option network 'lan'
|
||||
option encryption 'psk2'
|
||||
option key '${WIFI_PWD}'
|
||||
option ieee80211r '1'
|
||||
option mobility_domain '7da1'
|
||||
option ft_over_ds '0'
|
||||
|
||||
config wifi-iface 'wifi2g'
|
||||
option ssid 'kosovsky-main'
|
||||
option disabled '0'
|
||||
option device 'radio1'
|
||||
option mode 'ap'
|
||||
option network 'lan'
|
||||
option encryption 'psk2'
|
||||
option key '${WIFI_PWD}'
|
||||
option ieee80211r '1'
|
||||
option mobility_domain '3333'
|
||||
option ft_over_ds '0'
|
||||
option ft_psk_generate_local '1'
|
||||
|
||||
EOF
|
||||
Reference in new issue
Block a user