From 526cf49fb56f5b7bf51c7ab288bbd84858ae9676 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Mon, 22 Jun 2020 19:53:34 -0400 Subject: [PATCH] integrating wifi container --- extra/wifi.yml | 18 ++++++++++++++++++ scripts/conf/wificfg.json | 16 ++++++++++++++++ scripts/services/Mistborn-wifi.service | 22 ++++++++++++++++++++++ scripts/subinstallers/wifi.sh | 11 +++++++++++ 4 files changed, 67 insertions(+) create mode 100644 extra/wifi.yml create mode 100644 scripts/conf/wificfg.json create mode 100644 scripts/services/Mistborn-wifi.service create mode 100755 scripts/subinstallers/wifi.sh diff --git a/extra/wifi.yml b/extra/wifi.yml new file mode 100644 index 0000000..94e0f8a --- /dev/null +++ b/extra/wifi.yml @@ -0,0 +1,18 @@ +version: '3' + +services: + wifi: + #user: root + image: cyber5k/wifi + container_name: mistborn_production_wifi + #labels: + # - "traefik.enable=true" + # - "traefik.port=80" + #env_file: + # - ../.envs/.production/.pihole + #command: /start + volumes: + - ../../mistborn_volumes/extra/wifi/wificfg.json:/cfg/wificfg.json + network_mode: host + privileged: true + diff --git a/scripts/conf/wificfg.json b/scripts/conf/wificfg.json new file mode 100644 index 0000000..af1d97a --- /dev/null +++ b/scripts/conf/wificfg.json @@ -0,0 +1,16 @@ +{ + "dnsmasq_cfg": { + "address": "/#/192.168.27.1", + "dhcp_range": "192.168.27.100,192.168.27.150,1h", + "vendor_class": "set:device,IoT" + }, + "host_apd_cfg": { + "ip": "192.168.27.1", + "ssid": "iot-wifi-cfg-3", + "wpa_passphrase":"iotwifipass", + "channel": "6" + }, + "wpa_supplicant_cfg": { + "cfg_file": "/etc/wpa_supplicant/wpa_supplicant.conf" + } +} diff --git a/scripts/services/Mistborn-wifi.service b/scripts/services/Mistborn-wifi.service new file mode 100644 index 0000000..5a65200 --- /dev/null +++ b/scripts/services/Mistborn-wifi.service @@ -0,0 +1,22 @@ +[Unit] +Description=Mistborn Wifi Service +Requires=Mistborn-base.service +After=Mistborn-base.service + +[Service] +Restart=always +User=root +Group=docker +PermissionsStartOnly=true +# Shutdown container (if running) when unit is stopped +ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml down + +ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml build +# Start container when unit is started +ExecStart=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml up +# Stop container when unit is stopped +ExecStop=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml down +# Post stop + +[Install] +WantedBy=multi-user.target diff --git a/scripts/subinstallers/wifi.sh b/scripts/subinstallers/wifi.sh new file mode 100755 index 0000000..e6d4e06 --- /dev/null +++ b/scripts/subinstallers/wifi.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# wpa_supplicant +sudo systemctl stop wpa_supplicant.service +sudo systemctl disable wpa_supplicant.service +sudo systemctl mask wpa_supplicant.service +sudo pkill wpa_supplicant + +# create wificfg.json +sudo mkdir -p /opt/mistborn_volumes/extra/wifi +sudo cp /opt/mistborn/scripts/conf/wificfg.json /opt/mistborn_volumes/extra/wifi/