wifidog-ng: Convert init script indentation to tabs
This is done to minimize disk space used. This also removes some trailing spaces. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
parent
f5181d615c
commit
353c51a251
1 changed files with 72 additions and 72 deletions
|
@ -8,114 +8,114 @@ BIN=/usr/bin/wifidog-ng
|
||||||
dhcp_host_white=1
|
dhcp_host_white=1
|
||||||
|
|
||||||
start_wifidog() {
|
start_wifidog() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local enabled interface
|
local enabled interface
|
||||||
|
|
||||||
uci_validate_section wifidog-ng gateway "${1}" \
|
uci_validate_section wifidog-ng gateway "${1}" \
|
||||||
'enabled:bool:0' \
|
'enabled:bool:0' \
|
||||||
'interface:uci("network", "@interface"):lan' \
|
'interface:uci("network", "@interface"):lan' \
|
||||||
'dhcp_host_white:bool:1'
|
'dhcp_host_white:bool:1'
|
||||||
|
|
||||||
[ $? -ne 0 ] && {
|
[ $? -ne 0 ] && {
|
||||||
echo "validation gateway failed" >&2
|
echo "validation gateway failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ $enabled -eq 1 ] || exit 0
|
[ $enabled -eq 1 ] || exit 0
|
||||||
|
|
||||||
# timeout = 49 days
|
# timeout = 49 days
|
||||||
ipset -! create wifidog-ng-mac hash:mac timeout 4294967
|
ipset -! create wifidog-ng-mac hash:mac timeout 4294967
|
||||||
ipset -! create wifidog-ng-ip hash:ip
|
ipset -! create wifidog-ng-ip hash:ip
|
||||||
|
|
||||||
modprobe wifidog-ng
|
modprobe wifidog-ng
|
||||||
echo "enabled=1" > /proc/wifidog-ng/config
|
echo "enabled=1" > /proc/wifidog-ng/config
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command $BIN
|
procd_set_param command $BIN
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_server() {
|
parse_server() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local host
|
local host
|
||||||
|
|
||||||
config_get host $cfg host
|
config_get host $cfg host
|
||||||
validate_data ip4addr "$host" 2> /dev/null
|
validate_data ip4addr "$host" 2> /dev/null
|
||||||
if [ $? -eq 0 ];
|
if [ $? -eq 0 ];
|
||||||
then
|
then
|
||||||
ipset add wifidog-ng-ip $host
|
ipset add wifidog-ng-ip $host
|
||||||
else
|
else
|
||||||
echo "ipset=/$host/wifidog-ng-ip" >> /tmp/dnsmasq.d/wifidog-ng
|
echo "ipset=/$host/wifidog-ng-ip" >> /tmp/dnsmasq.d/wifidog-ng
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_validated_user() {
|
parse_validated_user() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local mac ip
|
local mac ip
|
||||||
|
|
||||||
uci_validate_section wifidog-ng validated_user "${1}" \
|
uci_validate_section wifidog-ng validated_user "${1}" \
|
||||||
'mac:macaddr'
|
'mac:macaddr'
|
||||||
|
|
||||||
[ $? -ne 0 ] && {
|
[ $? -ne 0 ] && {
|
||||||
echo "validation validated_user failed" >&2
|
echo "validation validated_user failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$mac" ] && ipset add wifidog-ng-mac $mac
|
[ -n "$mac" ] && ipset add wifidog-ng-mac $mac
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_validated_domain() {
|
parse_validated_domain() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local domain
|
local domain
|
||||||
|
|
||||||
uci_validate_section wifidog-ng validated_domain "${1}" \
|
uci_validate_section wifidog-ng validated_domain "${1}" \
|
||||||
'domain:host'
|
'domain:host'
|
||||||
|
|
||||||
[ $? -ne 0 ] && {
|
[ $? -ne 0 ] && {
|
||||||
echo "validation validated_domain failed" >&2
|
echo "validation validated_domain failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$domain" ] && echo "ipset=/$domain/wifidog-ng-ip" >> /tmp/dnsmasq.d/wifidog-ng
|
[ -n "$domain" ] && echo "ipset=/$domain/wifidog-ng-ip" >> /tmp/dnsmasq.d/wifidog-ng
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_dhcp_host() {
|
parse_dhcp_host() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local mac ip
|
local mac ip
|
||||||
|
|
||||||
uci_validate_section dhcp host "${1}" \
|
uci_validate_section dhcp host "${1}" \
|
||||||
'mac:macaddr'
|
'mac:macaddr'
|
||||||
|
|
||||||
[ $? -ne 0 ] && {
|
[ $? -ne 0 ] && {
|
||||||
echo "validation validated dhcp host failed" >&2
|
echo "validation validated dhcp host failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$mac" ] && ipset add wifidog-ng-mac $mac
|
[ -n "$mac" ] && ipset add wifidog-ng-mac $mac
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
config_load wifidog-ng
|
config_load wifidog-ng
|
||||||
config_foreach start_wifidog gateway
|
config_foreach start_wifidog gateway
|
||||||
|
|
||||||
echo -n > /tmp/dnsmasq.d/wifidog-ng
|
echo -n > /tmp/dnsmasq.d/wifidog-ng
|
||||||
|
|
||||||
config_foreach parse_server server
|
config_foreach parse_server server
|
||||||
config_foreach parse_validated_user validated_user
|
config_foreach parse_validated_user validated_user
|
||||||
config_foreach parse_validated_domain validated_domain
|
config_foreach parse_validated_domain validated_domain
|
||||||
|
|
||||||
[ $dhcp_host_white -eq 1 ] && {
|
[ $dhcp_host_white -eq 1 ] && {
|
||||||
config_load dhcp
|
config_load dhcp
|
||||||
config_foreach parse_dhcp_host host
|
config_foreach parse_dhcp_host host
|
||||||
}
|
}
|
||||||
|
|
||||||
/etc/init.d/dnsmasq restart &
|
/etc/init.d/dnsmasq restart &
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service() {
|
stop_service() {
|
||||||
rmmod wifidog-ng
|
rmmod wifidog-ng
|
||||||
|
|
||||||
ipset destroy wifidog-ng-mac
|
ipset destroy wifidog-ng-mac
|
||||||
ipset destroy wifidog-ng-ip
|
ipset destroy wifidog-ng-ip
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue