Compare commits
9 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0f1c7fbcf6 | 5 years ago |
|
|
ed6975e82d | 5 years ago |
|
|
b7ee2e87bc | 5 years ago |
|
|
c8c7663d08 | 5 years ago |
|
|
44e4a395fc | 5 years ago |
|
|
7a4498215b | 5 years ago |
|
|
255e1d5ecf | 6 years ago |
|
|
01cbf98b51 | 6 years ago |
|
|
526cf49fb5 | 6 years ago |
7 changed files with 147 additions and 0 deletions
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
version: '3' |
||||
|
||||
services: |
||||
wifi: |
||||
#user: root |
||||
image: "cyber5k/wifi:${MISTBORN_TAG}" |
||||
container_name: mistborn_production_wifi |
||||
#labels: |
||||
# - "traefik.enable=true" |
||||
# - "traefik.port=80" |
||||
#env_file: |
||||
# - ../.envs/.production/.pihole |
||||
#command: /start |
||||
volumes: |
||||
- ../../mistborn_volumes/extra/wifi/hostapd.conf:/etc/hostapd/hostapd.conf |
||||
- ../../mistborn_volumes/extra/wifi/dnsmasq.conf:/etc/dnsmasq.conf |
||||
# - ../../mistborn_volumes/extra/wifi/wificfg.json:/cfg/wificfg.json |
||||
network_mode: bridge #host |
||||
cap_add: |
||||
- NET_ADMIN |
||||
- NET_RAW |
||||
#privileged: true |
||||
|
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
{ |
||||
"wifi_iface": "wlan0", |
||||
"dnsmasq_cfg": { |
||||
"address": "/#/192.168.27.1", |
||||
"dhcp_range": "192.168.27.100,192.168.27.150,1h", |
||||
"dhcp_option": "6,10.2.3.1", |
||||
"vendor_class": "set:device,IoT" |
||||
}, |
||||
"host_apd_cfg": { |
||||
"ip": "192.168.27.1", |
||||
"ssid": "mistborn", |
||||
"wpa_passphrase":"iotwifipass", |
||||
"channel": "6" |
||||
}, |
||||
"wpa_supplicant_cfg": { |
||||
"cfg_file": "/etc/wpa_supplicant/wpa_supplicant.conf" |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
[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 |
||||
EnvironmentFile=/opt/mistborn/.env |
||||
|
||||
ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml down |
||||
ExecStartPre=/opt/mistborn/scripts/services/wifi/init.sh |
||||
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 |
||||
|
||||
ExecStartPost=/opt/mistborn/scripts/services/wifi/start.sh |
||||
|
||||
# Stop container when unit is stopped |
||||
ExecStop=/usr/local/bin/docker-compose -f /opt/mistborn/extra/wifi.yml down |
||||
# Post stop |
||||
ExecStopPost=/opt/mistborn/scripts/services/wifi/stop.sh |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash |
||||
|
||||
# Colors |
||||
MAGENTA='\e[0;35m' |
||||
RED='\e[0;31m' |
||||
GREEN='\e[0;32m' |
||||
BLUE='\e[0;34m' |
||||
NC='\e[0m' |
||||
|
||||
# Check that the interface exists and its not in use. Returns iface phy |
||||
iface_check (){ |
||||
IFACE="$1" |
||||
|
||||
# Check that the requested iface is available |
||||
if ! [ -e /sys/class/net/"$IFACE" ] |
||||
then |
||||
echo -e "${RED}[ERROR]${NC} The interface provided does not exist. Exiting..." |
||||
exit 1 |
||||
fi |
||||
|
||||
# Check that the given interface is not used by the host as the default route |
||||
if [[ $(ip r | grep default | cut -d " " -f5) == "$IFACE" ]] |
||||
then |
||||
echo -e "${BLUE}[INFO]${NC} The selected interface is configured as the default route, if you use it you will lose internet connectivity" |
||||
exit 1; |
||||
fi |
||||
|
||||
# Find the physical interface for the given wireless interface |
||||
PHY=$(cat /sys/class/net/"$IFACE"/phy80211/name) |
||||
echo $PHY |
||||
} |
||||
|
||||
hostapd_setup() { |
||||
### Check if hostapd is running in the host |
||||
hostapd_pid=$(pgrep hostapd) |
||||
if [ ! "$hostapd_pid" == "" ] |
||||
then |
||||
echo -e "${BLUE}[INFO]${NC} hostapd service is already running in the system, make sure you use a different wireless interface..." |
||||
#kill -9 "$hostapd_pid" |
||||
fi |
||||
|
||||
# Unblock wifi and bring the wireless interface up |
||||
echo -e "${BLUE}[INFO]${NC} Unblocking wifi and setting ${IFACE} up" |
||||
rfkill unblock wifi |
||||
ip link set "$IFACE" up |
||||
|
||||
# Check if a wlan config file exists, else take wlan parameters by default |
||||
if [ -e "$PATHSCRIPT"/"$CONF_FILE" ] |
||||
then |
||||
echo -e "${BLUE}[INFO]${NC} Found WLAN config file" |
||||
# Parse the wlan config file |
||||
IFS="=" |
||||
while read -r name value |
||||
do |
||||
case $name in |
||||
''|\#* ) continue;; # Skip blank lines and lines starting with # |
||||
"SSID" ) |
||||
SSID=${value//\"/} |
||||
echo -e "${BLUE}"[INFO]"${NC}" SSID: "${MAGENTA}""$SSID""${NC}";; |
||||
"PASSPHRASE" ) |
||||
PASSPHRASE=${value//\"/};; |
||||
"HW_MODE" ) |
||||
HW_MODE=${value//\"/};; |
||||
"CHANNEL" ) |
||||
CHANNEL=${value//\"/};; |
||||
* ) |
||||
echo Parameter "$name" in "$PATHSCRIPT"/"$CONF_FILE" not recognized |
||||
esac |
||||
done < "$PATHSCRIPT"/"$CONF_FILE" |
||||
else |
||||
echo -e "${BLUE}[INFO]${NC} WLAN config file not found. Setting default WLAN parameters" |
||||
echo -e "${BLUE}"[INFO]"${NC}" SSID: "${MAGENTA}""$SSID""${NC}" |
||||
fi |
||||
|
||||
} |
||||
Loading…
Reference in new issue