1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00
hotspot_ynh/sources/captiveportal_allow
2024-08-17 00:51:49 +02:00

11 lines
478 B
Bash

#!/bin/bash
date=$(date +"%Y-%m-%d %T")
ip=$1
mac=$(arp -a $ip | cut -d" " -f4 | head -n1)
interface=$(grep wifi_device /etc/yunohost/apps/hotspot/settings.yml | cut -d: -f2 | sed "s/[ ']//g")
if ! grep $mac /etc/hostapd/$app/allowed.csv ; then
echo "$date,$ip,$mac" >> /etc/hostapd/$app/allowed.csv
iptables -w -I hotspot_fwd 1 -s $ip -m mac --mac-source $mac -j ACCEPT
iptables -t nat -w -I PREROUTING 1 -i $interface -s $ip -m mac --mac-source $mac -j ACCEPT
fi