mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
beta multissid
This commit is contained in:
parent
5aa581e147
commit
ab39322ebd
11 changed files with 322 additions and 219 deletions
13
TODO
13
TODO
|
@ -1 +1,14 @@
|
||||||
* Translate PHP interface in French
|
* Translate PHP interface in French
|
||||||
|
|
||||||
|
* multissid
|
||||||
|
** WEB: limit to N ssid max depending on the antenna specs
|
||||||
|
** WEB: add ssid delete feature
|
||||||
|
** WEB: update is_connected_through_hotspot feature
|
||||||
|
** WEB: autocomplete ipv4 nat prefix (.242, .243, .244, etc)
|
||||||
|
** WEB: check if ipv6 delgated prefixes and ipv4 nat prefixes are unique
|
||||||
|
** WEB: fix the now broken wifiparty button
|
||||||
|
** INIT: differentiate ipv6 and ipv4 in is_dhcpd_running
|
||||||
|
** INIT: do not attribute a static mac address
|
||||||
|
** INIT: use insserv instead of update-rc.d and update service dependencies
|
||||||
|
** HARD: try with olimex antenna (no multissid enabled)
|
||||||
|
** MISC: update vpnclient/torclient for enabling the user to choose the correct ssid
|
||||||
|
|
47
conf/dhcpdv4.conf.tpl
Normal file
47
conf/dhcpdv4.conf.tpl
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# Wifi Hotspot app for YunoHost
|
||||||
|
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
||||||
|
# Contribute at https://github.com/jvaubourg/hotspot_ynh
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Do DHCP for this subnet.
|
||||||
|
dhcp-range=interface:<TPL:WIFI_DEVICE>,<TPL:IP4_NAT_PREFIX>.2,<TPL:IP4_NAT_PREFIX>.254,4h
|
||||||
|
|
||||||
|
# Send DHCPv4 option.
|
||||||
|
dhcp-option=option:dns-server,<TPL:IP4_DNS0>,<TPL:IP4_DNS1>
|
||||||
|
|
||||||
|
# Set the DHCP server to authoritative mode. In this mode it will barge in
|
||||||
|
# and take over the lease for any client which broadcasts on the network,
|
||||||
|
# whether it has a record of the lease or not. This avoids long timeouts
|
||||||
|
# when a machine wakes up on a new network. DO NOT enable this if there's
|
||||||
|
# the slightest chance that you might end up accidentally configuring a DHCP
|
||||||
|
# server for your campus/company accidentally. The ISC server uses
|
||||||
|
# the same option, and this URL provides more information:
|
||||||
|
# http://www.isc.org/files/auth.html
|
||||||
|
dhcp-authoritative
|
||||||
|
|
||||||
|
# On systems which support it, dnsmasq binds the wildcard address,
|
||||||
|
# even when it is listening on only some interfaces. It then discards
|
||||||
|
# requests that it shouldn't reply to. This has the advantage of
|
||||||
|
# working even when interfaces come and go and change address. If you
|
||||||
|
# want dnsmasq to really bind only the interfaces it is listening on,
|
||||||
|
# uncomment this option. About the only time you may need this is when
|
||||||
|
# running another nameserver on the same machine.
|
||||||
|
bind-interfaces
|
||||||
|
|
||||||
|
# If this line is uncommented, dnsmasq will read /etc/ethers and act
|
||||||
|
# on the ethernet-address/IP pairs found there just as if they had
|
||||||
|
# been given as --dhcp-host options. Useful if you keep
|
||||||
|
# MAC-address/host mappings there for other purposes.
|
||||||
|
#read-ethers
|
23
conf/dhcpdv6.conf.tpl
Normal file
23
conf/dhcpdv6.conf.tpl
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Wifi Hotspot app for YunoHost
|
||||||
|
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
||||||
|
# Contribute at https://github.com/jvaubourg/hotspot_ynh
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Do DHCP and Router Advertisements for this subnet. Set the A bit in the RA
|
||||||
|
# so that clients can use SLAAC addresses as well as DHCP ones.
|
||||||
|
dhcp-range=interface:<TPL:WIFI_DEVICE>,<TPL:IP6_NET>,slaac,64,4h
|
||||||
|
|
||||||
|
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
||||||
|
dhcp-option=option6:dns-server,[<TPL:IP6_DNS0>],[<TPL:IP6_DNS1>]
|
|
@ -16,19 +16,11 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
interface=<TPL:WIFI_DEVICE>
|
interface=<TPL:WIFI_DEVICE>
|
||||||
ssid=<TPL:WIFI_SSID>
|
|
||||||
|
|
||||||
hw_mode=g
|
hw_mode=g
|
||||||
<TPL:N_COMMENT>ieee80211n=1
|
<TPL:N_COMMENT>ieee80211n=1
|
||||||
<TPL:N_COMMENT>wmm_enabled=1
|
<TPL:N_COMMENT>wmm_enabled=1
|
||||||
|
|
||||||
channel=<TPL:WIFI_CHANNEL>
|
|
||||||
macaddr_acl=0
|
macaddr_acl=0
|
||||||
auth_algs=1
|
auth_algs=1
|
||||||
ignore_broadcast_ssid=0
|
ignore_broadcast_ssid=0
|
||||||
|
channel=<TPL:WIFI_CHANNEL>
|
||||||
|
|
||||||
<TPL:SEC_COMMENT>wpa=2
|
|
||||||
<TPL:SEC_COMMENT>wpa_passphrase=<TPL:WIFI_PASSPHRASE>
|
|
||||||
<TPL:SEC_COMMENT>wpa_key_mgmt=WPA-PSK
|
|
||||||
<TPL:SEC_COMMENT>wpa_pairwise=TKIP
|
|
||||||
<TPL:SEC_COMMENT>rsn_pairwise=CCMP
|
|
8
conf/hostapd.conf.tpl2
Normal file
8
conf/hostapd.conf.tpl2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
bss=<TPL:WIFI_INTERFACE>
|
||||||
|
ssid=<TPL:WIFI_SSID>
|
||||||
|
<TPL:SEC_COMMENT>wpa=2
|
||||||
|
<TPL:SEC_COMMENT>wpa_passphrase=<TPL:WIFI_PASSPHRASE>
|
||||||
|
<TPL:SEC_COMMENT>wpa_key_mgmt=WPA-PSK
|
||||||
|
<TPL:SEC_COMMENT>wpa_pairwise=TKIP
|
||||||
|
<TPL:SEC_COMMENT>rsn_pairwise=CCMP
|
||||||
|
|
|
@ -34,7 +34,9 @@ has_vpnclient_app() {
|
||||||
}
|
}
|
||||||
|
|
||||||
has_ip6delegatedprefix() {
|
has_ip6delegatedprefix() {
|
||||||
[ "${ynh_ip6_net}" != none ]
|
i=${1}
|
||||||
|
|
||||||
|
[ "${ynh_ip6_net[${i}]}" != none ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_nat_set() {
|
is_nat_set() {
|
||||||
|
@ -44,11 +46,15 @@ is_nat_set() {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_ip4nataddr_set() {
|
is_ip4nataddr_set() {
|
||||||
ip address show dev "${ynh_wifi_device}" 2> /dev/null | grep -q "${ynh_ip4_nat_prefix}.1/24"
|
i=${1}
|
||||||
|
|
||||||
|
ip address show dev "ssid${i}" 2> /dev/null | grep -q "${ynh_ip4_nat_prefix[${i}]}.1/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_ip6addr_set() {
|
is_ip6addr_set() {
|
||||||
ip address show dev "${ynh_wifi_device}" 2> /dev/null | grep -q "${ynh_ip6_addr}/64"
|
i=${1}
|
||||||
|
|
||||||
|
ip address show dev "ssid${i}" 2> /dev/null | grep -q "${ynh_ip6_addr[${i}]}/64"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_forwarding_set() {
|
is_forwarding_set() {
|
||||||
|
@ -58,39 +64,27 @@ is_forwarding_set() {
|
||||||
[ "${ip6}" -eq 1 -a "${ip4}" -eq 1 ]
|
[ "${ip6}" -eq 1 -a "${ip4}" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_dhcpdv6_set() {
|
is_dhcpd_running() {
|
||||||
[ -e /etc/dnsmasq.d/dhcpdv6.conf ]
|
i=${1}
|
||||||
}
|
|
||||||
|
|
||||||
is_dhcpdv4_set() {
|
$(ps aux | grep "dhcpdv.-ssid${i}" | grep -qv grep)
|
||||||
[ -e /etc/dnsmasq.d/dhcpdv4.conf ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_hostapd_running() {
|
is_hostapd_running() {
|
||||||
service hostapd status &> /dev/null
|
service hostapd status &> /dev/null
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
|
|
||||||
# If the wifi antenna was unplugged
|
|
||||||
if ip link show dev "${ynh_wifi_device}" | grep -q DOWN; then
|
|
||||||
service hostapd stop &> /dev/null
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
is_dnsmasq_running() {
|
|
||||||
service dnsmasq status &> /dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_running() {
|
is_running() {
|
||||||
( has_ip6delegatedprefix && is_ip6addr_set && is_dhcpdv6_set || ! has_ip6delegatedprefix )\
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
&& is_nat_set "${new_internet_device}" && is_ip4nataddr_set && is_forwarding_set && is_hostapd_running\
|
( has_ip6delegatedprefix ${i} && is_ip6addr_set ${i} || ! has_ip6delegatedprefix ${i} )\
|
||||||
&& is_dhcpdv4_set && is_dnsmasq_running
|
&& is_ip4nataddr_set ${i} && is_dhcpd_running ${i}
|
||||||
|
|
||||||
|
if [ ! $? -eq 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
is_hostapd_running && is_forwarding_set && is_nat_set "${new_internet_device}"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Setters
|
## Setters
|
||||||
|
@ -102,12 +96,16 @@ set_nat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ip4nataddr() {
|
set_ip4nataddr() {
|
||||||
ip address add "${ynh_ip4_nat_prefix}.1/24" dev "${ynh_wifi_device}"
|
i=${1}
|
||||||
|
|
||||||
|
ip address add "${ynh_ip4_nat_prefix[${i}]}.1/24" dev "ssid${i}"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ip6addr() {
|
set_ip6addr() {
|
||||||
ip address delete "${ynh_ip6_addr}/64" dev tun0 &> /dev/null
|
i=${1}
|
||||||
ip address add "${ynh_ip6_addr}/64" dev "${ynh_wifi_device}"
|
|
||||||
|
ip address delete "${ynh_ip6_addr[${i}]}/64" dev tun0 &> /dev/null
|
||||||
|
ip address add "${ynh_ip6_addr[${i}]}/64" dev "ssid${i}"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_forwarding() {
|
set_forwarding() {
|
||||||
|
@ -115,44 +113,64 @@ set_forwarding() {
|
||||||
sysctl -w net.ipv4.conf.all.forwarding=1 > /dev/null
|
sysctl -w net.ipv4.conf.all.forwarding=1 > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dhcpd() {
|
start_dhcpd() {
|
||||||
if has_ip6delegatedprefix; then
|
i=${1}
|
||||||
cp /etc/dnsmasq.d.tpl/dhcpdv6.conf.tpl /etc/dnsmasq.d/dhcpdv6.conf
|
|
||||||
|
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/dnsmasq.d/dhcpdv6.conf
|
rm -f /etc/dnsmasq.dhcpd/dhcpdv?-ssid*.conf
|
||||||
sed "s|<TPL:IP6_NET>|${ynh_ip6_net}|g" -i /etc/dnsmasq.d/dhcpdv6.conf
|
|
||||||
sed "s|<TPL:IP6_DNS0>|${ynh_ip6_dns0}|g" -i /etc/dnsmasq.d/dhcpdv6.conf
|
if has_ip6delegatedprefix ${i}; then
|
||||||
sed "s|<TPL:IP6_DNS1>|${ynh_ip6_dns1}|g" -i /etc/dnsmasq.d/dhcpdv6.conf
|
cp /etc/dnsmasq.dhcpdhcpd/dhcpdv6{.conf.tpl,-ssid${i}.conf}
|
||||||
|
|
||||||
|
sed "s|<TPL:WIFI_DEVICE>|ssid${i}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
|
sed "s|<TPL:IP6_NET>|${ynh_ip6_net[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
|
sed "s|<TPL:IP6_DNS0>|${ynh_ip6_dns0[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
|
sed "s|<TPL:IP6_DNS1>|${ynh_ip6_dns1[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
|
|
||||||
|
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf -p0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp /etc/dnsmasq.d.tpl/dhcpdv4.conf.tpl /etc/dnsmasq.d/dhcpdv4.conf
|
cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
|
||||||
|
|
||||||
sed "s|<TPL:IP4_DNS0>|${ynh_ip4_dns0}|g" -i /etc/dnsmasq.d/dhcpdv4.conf
|
sed "s|<TPL:IP4_DNS0>|${ynh_ip4_dns0[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
sed "s|<TPL:IP4_DNS1>|${ynh_ip4_dns1}|g" -i /etc/dnsmasq.d/dhcpdv4.conf
|
sed "s|<TPL:IP4_DNS1>|${ynh_ip4_dns1[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/dnsmasq.d/dhcpdv4.conf
|
sed "s|<TPL:WIFI_DEVICE>|ssid${i}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
sed "s|<TPL:IP4_NAT_PREFIX>|${ynh_ip4_nat_prefix}|g" -i /etc/dnsmasq.d/dhcpdv4.conf
|
sed "s|<TPL:IP4_NAT_PREFIX>|${ynh_ip4_nat_prefix[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
|
|
||||||
|
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
|
||||||
}
|
}
|
||||||
|
|
||||||
start_hostapd() {
|
start_hostapd() {
|
||||||
cp /etc/hostapd/hostapd.conf{.tpl,}
|
cp /etc/hostapd/hostapd.conf{.tpl1,}
|
||||||
|
|
||||||
|
ip link set addr 02:42:42:13:37:00 dev "${ynh_wifi_device}"
|
||||||
|
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/hostapd/hostapd.conf
|
sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/hostapd/hostapd.conf
|
||||||
sed "s|<TPL:WIFI_SSID>|${ynh_wifi_ssid}|g" -i /etc/hostapd/hostapd.conf
|
|
||||||
sed "s|<TPL:WIFI_PASSPHRASE>|${ynh_wifi_passphrase}|g" -i /etc/hostapd/hostapd.conf
|
|
||||||
sed "s|<TPL:WIFI_CHANNEL>|${ynh_wifi_channel}|g" -i /etc/hostapd/hostapd.conf
|
sed "s|<TPL:WIFI_CHANNEL>|${ynh_wifi_channel}|g" -i /etc/hostapd/hostapd.conf
|
||||||
|
|
||||||
if [ "${ynh_wifi_n}" -eq 1 ]; then
|
iwconfig "${ynh_wifi_device}" | grep -q 'n *ESSID'
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
sed "s|<TPL:N_COMMENT>||g" -i /etc/hostapd/hostapd.conf
|
sed "s|<TPL:N_COMMENT>||g" -i /etc/hostapd/hostapd.conf
|
||||||
else
|
else
|
||||||
sed "s|<TPL:N_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf
|
sed "s|<TPL:N_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${ynh_wifi_secure}" -eq 1 ]; then
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
sed "s|<TPL:SEC_COMMENT>||g" -i /etc/hostapd/hostapd.conf
|
cp /etc/hostapd/hostapd.conf{.tpl2,.tmp}
|
||||||
|
|
||||||
|
sed "s|<TPL:WIFI_INTERFACE>|ssid${i}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
|
sed "s|<TPL:WIFI_SSID>|${ynh_wifi_ssid[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
|
sed "s|<TPL:WIFI_PASSPHRASE>|${ynh_wifi_passphrase[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
|
|
||||||
|
if [ "${ynh_wifi_secure[${i}]}" -eq 1 ]; then
|
||||||
|
sed "s|<TPL:SEC_COMMENT>||g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
else
|
else
|
||||||
sed "s|<TPL:SEC_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf
|
sed "s|<TPL:SEC_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
|
||||||
|
rm /etc/hostapd/hostapd.conf.tmp
|
||||||
|
done
|
||||||
|
|
||||||
service hostapd start
|
service hostapd start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,15 +183,15 @@ unset_nat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unset_ip4nataddr() {
|
unset_ip4nataddr() {
|
||||||
ip address delete "${ynh_ip4_nat_prefix}.1/24" dev "${ynh_wifi_device}"
|
i=${1}
|
||||||
|
|
||||||
|
ip address delete "${ynh_ip4_nat_prefix[${i}]}.1/24" dev "ssid${i}"
|
||||||
}
|
}
|
||||||
|
|
||||||
unset_ip6addr() {
|
unset_ip6addr() {
|
||||||
ip address delete "${ynh_ip6_addr}/64" dev "${ynh_wifi_device}"
|
i=${1}
|
||||||
}
|
|
||||||
|
|
||||||
unset_dhcpd() {
|
ip address delete "${ynh_ip6_addr[${i}]}/64" dev "ssid${i}"
|
||||||
rm -f /etc/dnsmasq.d/dhcpdv?.conf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset_forwarding() {
|
unset_forwarding() {
|
||||||
|
@ -181,6 +199,11 @@ unset_forwarding() {
|
||||||
sysctl -w net.ipv4.conf.all.forwarding=0 > /dev/null
|
sysctl -w net.ipv4.conf.all.forwarding=0 > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_dhcpd() {
|
||||||
|
kill $(ps aux | grep 'dhcpdv.-ssid' | grep -v grep | awk '{ print $2 }')
|
||||||
|
rm -f /etc/dnsmasq.d/dhcpdv?-ssid*.conf
|
||||||
|
}
|
||||||
|
|
||||||
stop_hostapd() {
|
stop_hostapd() {
|
||||||
service hostapd stop
|
service hostapd stop
|
||||||
}
|
}
|
||||||
|
@ -239,18 +262,19 @@ if [ "$1" != restart ]; then
|
||||||
|
|
||||||
ynh_service_enabled=$(moulinette_get service_enabled)
|
ynh_service_enabled=$(moulinette_get service_enabled)
|
||||||
ynh_wifi_device=$(moulinette_get wifi_device)
|
ynh_wifi_device=$(moulinette_get wifi_device)
|
||||||
ynh_wifi_ssid=$(moulinette_get wifi_ssid)
|
|
||||||
ynh_wifi_secure=$(moulinette_get wifi_secure)
|
|
||||||
ynh_wifi_passphrase=$(moulinette_get wifi_passphrase)
|
|
||||||
ynh_wifi_channel=$(moulinette_get wifi_channel)
|
ynh_wifi_channel=$(moulinette_get wifi_channel)
|
||||||
ynh_wifi_n=$(moulinette_get wifi_n)
|
ynh_multissid=$(moulinette_get multissid)
|
||||||
ynh_ip6_addr=$(moulinette_get ip6_addr)
|
|
||||||
ynh_ip6_net=$(moulinette_get ip6_net)
|
IFS='|' read -a ynh_wifi_ssid <<< "$(moulinette_get wifi_ssid)"
|
||||||
ynh_ip6_dns0=$(moulinette_get ip6_dns0)
|
IFS='|' read -a ynh_wifi_secure <<< "$(moulinette_get wifi_secure)"
|
||||||
ynh_ip6_dns1=$(moulinette_get ip6_dns1)
|
IFS='|' read -a ynh_wifi_passphrase <<< "$(moulinette_get wifi_passphrase)"
|
||||||
ynh_ip4_dns0=$(moulinette_get ip4_dns0)
|
IFS='|' read -a ynh_ip6_addr <<< "$(moulinette_get ip6_addr)"
|
||||||
ynh_ip4_dns1=$(moulinette_get ip4_dns1)
|
IFS='|' read -a ynh_ip6_net <<< "$(moulinette_get ip6_net)"
|
||||||
ynh_ip4_nat_prefix=$(moulinette_get ip4_nat_prefix)
|
IFS='|' read -a ynh_ip6_dns0 <<< "$(moulinette_get ip6_dns0)"
|
||||||
|
IFS='|' read -a ynh_ip6_dns1 <<< "$(moulinette_get ip6_dns1)"
|
||||||
|
IFS='|' read -a ynh_ip4_dns0 <<< "$(moulinette_get ip4_dns0)"
|
||||||
|
IFS='|' read -a ynh_ip4_dns1 <<< "$(moulinette_get ip4_dns1)"
|
||||||
|
IFS='|' read -a ynh_ip4_nat_prefix <<< "$(moulinette_get ip4_nat_prefix)"
|
||||||
|
|
||||||
old_internet_device=$(moulinette_get internet_device)
|
old_internet_device=$(moulinette_get internet_device)
|
||||||
new_internet_device=$(ip route | awk '/default via/ { print $NF; }')
|
new_internet_device=$(ip route | awk '/default via/ { print $NF; }')
|
||||||
|
@ -264,21 +288,21 @@ if [ "$1" != restart ]; then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|
||||||
# Check IPv6 delegated prefix from vpnclient
|
# Check IPv6 delegated prefix from vpnclient
|
||||||
vpnclient_ip6_net=$(moulinette_vpnclient_get ip6_net)
|
# vpnclient_ip6_net=$(moulinette_vpnclient_get ip6_net)
|
||||||
|
#
|
||||||
if [ ! -z "${vpnclient_ip6_addr}" ]; then
|
# if [ ! -z "${vpnclient_ip6_addr}" ]; then
|
||||||
if [ "${ynh_ip6_net}" == none ]; then
|
# if [ "${ynh_ip6_net}" == none ]; then
|
||||||
ynh_ip6_net=$vpnclient_ip6_net
|
# ynh_ip6_net=$vpnclient_ip6_net
|
||||||
ynh_ip6_addr=$(moulinette_vpnclient_get ip6_addr)
|
# ynh_ip6_addr=$(moulinette_vpnclient_get ip6_addr)
|
||||||
|
#
|
||||||
moulinette_set ip6_net "${ynh_ip6_net}"
|
# moulinette_set ip6_net "${ynh_ip6_net}"
|
||||||
moulinette_set ip6_addr "${ynh_ip6_addr}"
|
# moulinette_set ip6_addr "${ynh_ip6_addr}"
|
||||||
else
|
# else
|
||||||
if [ "${ynh_ip6_net}" != "${vpnclient_ip6_net}" ]; then
|
# if [ "${ynh_ip6_net}" != "${vpnclient_ip6_net}" ]; then
|
||||||
echo "[WARN] The IPv6 delegated prefix is different from the vpnclient one"
|
# echo "[WARN] The IPv6 delegated prefix is different from the vpnclient one"
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -313,18 +337,6 @@ case "$1" in
|
||||||
set_nat "${new_internet_device}"
|
set_nat "${new_internet_device}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set ipv4 NAT address
|
|
||||||
if ! is_ip4nataddr_set; then
|
|
||||||
echo "Set IPv4 NAT address"
|
|
||||||
set_ip4nataddr
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set the ipv6 address
|
|
||||||
if has_ip6delegatedprefix && ! is_ip6addr_set; then
|
|
||||||
echo "Set IPv6 address"
|
|
||||||
set_ip6addr
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set forwarding for ipv6 and ipv4
|
# Set forwarding for ipv6 and ipv4
|
||||||
if ! is_forwarding_set; then
|
if ! is_forwarding_set; then
|
||||||
echo "Set forwarding"
|
echo "Set forwarding"
|
||||||
|
@ -334,18 +346,41 @@ case "$1" in
|
||||||
# Run hostapd
|
# Run hostapd
|
||||||
if ! is_hostapd_running; then
|
if ! is_hostapd_running; then
|
||||||
echo "Run hostapd"
|
echo "Run hostapd"
|
||||||
start_hostapd
|
start_hostapd ${i}
|
||||||
|
|
||||||
|
if [ ! $? -eq 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0; false || while [ $? -ne 0 ]; do
|
||||||
|
sleep 1 && (( i++ ))
|
||||||
|
[ ${i} -gt 20 ] && stop_hostapd
|
||||||
|
[ ${i} -gt 20 ] && exit 1
|
||||||
|
ip link show dev ssid0 &> /dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For each registred ssid
|
||||||
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
|
|
||||||
|
# Set ipv4 NAT address
|
||||||
|
if ! is_ip4nataddr_set ${i}; then
|
||||||
|
echo "Set IPv4 NAT address"
|
||||||
|
set_ip4nataddr ${i}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the ipv6 address
|
||||||
|
if has_ip6delegatedprefix ${i} && ! is_ip6addr_set ${i}; then
|
||||||
|
echo "Set IPv6 address"
|
||||||
|
set_ip6addr ${i}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run DHCP servers
|
# Run DHCP servers
|
||||||
if ( has_ip6delegatedprefix && ! is_dhcpdv6_set ) || ! is_dhcpdv4_set; then
|
if ! is_dhcpd_running ${i}; then
|
||||||
echo "Set DHCP servers (dnsmasq)"
|
echo "Set DHCP servers (dnsmasq)"
|
||||||
set_dhcpd
|
start_dhcpd ${i}
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
# Restart dhcpd
|
|
||||||
service bind9 stop &> /dev/null
|
|
||||||
service dnsmasq restart
|
|
||||||
|
|
||||||
# Update dynamic settings
|
# Update dynamic settings
|
||||||
moulinette_set internet_device "${new_internet_device}"
|
moulinette_set internet_device "${new_internet_device}"
|
||||||
|
@ -360,26 +395,28 @@ case "$1" in
|
||||||
unset_nat "${old_internet_device}"
|
unset_nat "${old_internet_device}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_ip4nataddr_set; then
|
|
||||||
echo "Unset IPv4 NAT address"
|
|
||||||
unset_ip4nataddr
|
|
||||||
fi
|
|
||||||
|
|
||||||
if has_ip6delegatedprefix && is_ip6addr_set; then
|
|
||||||
echo "Unset IPv6 address"
|
|
||||||
unset_ip6addr
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_forwarding_set; then
|
if is_forwarding_set; then
|
||||||
echo "Unset forwarding"
|
echo "Unset forwarding"
|
||||||
unset_forwarding
|
unset_forwarding
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_dhcpdv6_set || is_dhcpdv4_set; then
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
echo "Stop DHCP servers"
|
if is_ip4nataddr_set ${i}; then
|
||||||
unset_dhcpd
|
echo "Unset IPv4 NAT address"
|
||||||
|
unset_ip4nataddr ${i}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if has_ip6delegatedprefix ${i} && is_ip6addr_set ${i}; then
|
||||||
|
echo "Unset IPv6 address"
|
||||||
|
unset_ip6addr ${i}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_dhcpd_running ${i}; then
|
||||||
|
echo "Stop DHCP servers"
|
||||||
|
stop_dhcpd ${i}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if is_hostapd_running; then
|
if is_hostapd_running; then
|
||||||
echo "Stop hostapd"
|
echo "Stop hostapd"
|
||||||
stop_hostapd
|
stop_hostapd
|
||||||
|
@ -388,8 +425,6 @@ case "$1" in
|
||||||
if has_vpnclient_app; then
|
if has_vpnclient_app; then
|
||||||
service ynh-vpnclient start
|
service ynh-vpnclient start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
service dnsmasq restart
|
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
@ -405,34 +440,6 @@ case "$1" in
|
||||||
|
|
||||||
echo "[INFO] Autodetected internet interface: ${new_internet_device} (last start: ${old_internet_device})"
|
echo "[INFO] Autodetected internet interface: ${new_internet_device} (last start: ${old_internet_device})"
|
||||||
|
|
||||||
if has_ip6delegatedprefix; then
|
|
||||||
echo "[INFO] IPv6 delegated prefix found"
|
|
||||||
echo "[INFO] IPv6 address computed from the delegated prefix: ${ynh_ip6_addr}"
|
|
||||||
|
|
||||||
if is_ip6addr_set; then
|
|
||||||
echo "[OK] IPv6 address set"
|
|
||||||
else
|
|
||||||
echo "[ERR] No IPv6 address set"
|
|
||||||
exitcode=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_dhcpdv6_set; then
|
|
||||||
echo "[OK] SLAAC & DHCPv6 server set"
|
|
||||||
else
|
|
||||||
echo "[ERR] No SLAAC & DHCPv6 server set"
|
|
||||||
exitcode=1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[INFO] No IPv6 delegated prefix found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_dhcpdv4_set; then
|
|
||||||
echo "[OK] DHCPv4 server set"
|
|
||||||
else
|
|
||||||
echo "[ERR] No DHCPv4 server set"
|
|
||||||
exitcode=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_nat_set "${new_internet_device}"; then
|
if is_nat_set "${new_internet_device}"; then
|
||||||
echo "[OK] IPv4 NAT set"
|
echo "[OK] IPv4 NAT set"
|
||||||
else
|
else
|
||||||
|
@ -440,13 +447,6 @@ case "$1" in
|
||||||
exitcode=1
|
exitcode=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_ip4nataddr_set; then
|
|
||||||
echo "[OK] IPv4 NAT address set"
|
|
||||||
else
|
|
||||||
echo "[ERR] No IPv4 NAT address set"
|
|
||||||
exitcode=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_forwarding_set; then
|
if is_forwarding_set; then
|
||||||
echo "[OK] IPv6/IPv4 forwarding set"
|
echo "[OK] IPv6/IPv4 forwarding set"
|
||||||
else
|
else
|
||||||
|
@ -454,13 +454,6 @@ case "$1" in
|
||||||
exitcode=1
|
exitcode=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_dnsmasq_running; then
|
|
||||||
echo "[OK] Dnsmasq is running"
|
|
||||||
else
|
|
||||||
echo "[ERR] Dnsmasq is not running"
|
|
||||||
exitcode=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_hostapd_running; then
|
if is_hostapd_running; then
|
||||||
echo "[OK] Hostapd is running"
|
echo "[OK] Hostapd is running"
|
||||||
else
|
else
|
||||||
|
@ -468,6 +461,36 @@ case "$1" in
|
||||||
exitcode=1
|
exitcode=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
|
if has_ip6delegatedprefix ${i}; then
|
||||||
|
echo "[INFO] SSID ${i}: IPv6 delegated prefix found"
|
||||||
|
echo "[INFO] SSID ${i}: IPv6 address computed from the delegated prefix: ${ynh_ip6_addr}"
|
||||||
|
|
||||||
|
if is_ip6addr_set ${i}; then
|
||||||
|
echo "[OK] SSID ${i}: IPv6 address set"
|
||||||
|
else
|
||||||
|
echo "[ERR] SSID ${i}: No IPv6 address set"
|
||||||
|
exitcode=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] SSID ${i}: No IPv6 delegated prefix found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_dhcpd_running ${i}; then
|
||||||
|
echo "[OK] SSID ${i}: DHCP servers set"
|
||||||
|
else
|
||||||
|
echo "[ERR] SSID ${i}: No DHCP servers set"
|
||||||
|
exitcode=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_ip4nataddr_set ${i}; then
|
||||||
|
echo "[OK] SSID ${i}: IPv4 NAT address set"
|
||||||
|
else
|
||||||
|
echo "[ERR] SSID ${i}: No IPv4 NAT address set"
|
||||||
|
exitcode=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
exit ${exitcode}
|
exit ${exitcode}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -102,26 +102,20 @@ if [ -z "${ip6_net}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wifi_device=$(sudo iwconfig 2>&1 | grep 802.11 | head -n1 | awk '{ print $1 }')
|
wifi_device=$(sudo iwconfig 2>&1 | grep 802.11 | head -n1 | awk '{ print $1 }')
|
||||||
wifi_n=0
|
|
||||||
|
|
||||||
if [ -z "${wifi_device}" ]; then
|
if [ -z "${wifi_device}" ]; then
|
||||||
echo "ERROR: No wifi interface found" >&2
|
echo "ERROR: No wifi interface found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo iwconfig "${wifi_device}" | grep -q 'n *ESSID'
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
wifi_n=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save arguments
|
# Save arguments
|
||||||
sudo yunohost app setting hotspot service_enabled -v 1
|
sudo yunohost app setting hotspot service_enabled -v 1
|
||||||
|
sudo yunohost app setting hotspot multissid -v 1
|
||||||
sudo yunohost app setting hotspot wifi_ssid -v "${wifi_ssid}"
|
sudo yunohost app setting hotspot wifi_ssid -v "${wifi_ssid}"
|
||||||
sudo yunohost app setting hotspot wifi_secure -v 1
|
sudo yunohost app setting hotspot wifi_secure -v 1
|
||||||
sudo yunohost app setting hotspot wifi_passphrase -v "${wifi_passphrase}"
|
sudo yunohost app setting hotspot wifi_passphrase -v "${wifi_passphrase}"
|
||||||
sudo yunohost app setting hotspot wifi_device -v "${wifi_device}"
|
sudo yunohost app setting hotspot wifi_device -v "${wifi_device}"
|
||||||
sudo yunohost app setting hotspot wifi_channel -v 6
|
sudo yunohost app setting hotspot wifi_channel -v 6
|
||||||
sudo yunohost app setting hotspot wifi_n -v "${wifi_n}"
|
|
||||||
sudo yunohost app setting hotspot ip6_addr -v "${ip6_addr}"
|
sudo yunohost app setting hotspot ip6_addr -v "${ip6_addr}"
|
||||||
sudo yunohost app setting hotspot ip6_net -v "${ip6_net}"
|
sudo yunohost app setting hotspot ip6_net -v "${ip6_net}"
|
||||||
sudo yunohost app setting hotspot ip6_dns0 -v 2001:913::8
|
sudo yunohost app setting hotspot ip6_dns0 -v 2001:913::8
|
||||||
|
@ -137,12 +131,12 @@ sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
|
||||||
|
|
||||||
# Copy confs
|
# Copy confs
|
||||||
sudo mkdir -pm 0755 /var/log/nginx/
|
sudo mkdir -pm 0755 /var/log/nginx/
|
||||||
sudo mkdir -pm 0755 /etc/dnsmasq.d.tpl/
|
sudo mkdir -pm 0755 /etc/dnsmasq.dhcpd/
|
||||||
sudo chown root: /etc/dnsmasq.d.tpl/
|
sudo chown root: /etc/dnsmasq.dhcpd/
|
||||||
|
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/
|
sudo install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl? /etc/hostapd/
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.d.tpl/dhcpdv6.conf.tpl
|
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv6.conf.tpl
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.d.tpl/dhcpdv4.conf.tpl
|
sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/nginx_wifiadmin.conf "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
sudo install -b -o root -g root -m 0644 ../conf/nginx_wifiadmin.conf "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
||||||
sudo install -b -o root -g root -m 0644 ../conf/phpfpm_wifiadmin.conf /etc/php5/fpm/pool.d/wifiadmin.conf
|
sudo install -b -o root -g root -m 0644 ../conf/phpfpm_wifiadmin.conf /etc/php5/fpm/pool.d/wifiadmin.conf
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ sudo yunohost firewall disallow --ipv6 UDP 547
|
||||||
sudo yunohost firewall disallow UDP 67
|
sudo yunohost firewall disallow UDP 67
|
||||||
|
|
||||||
# Remove confs
|
# Remove confs
|
||||||
sudo rm -fr /etc/dnsmasq.d.tpl/
|
sudo rm -fr /etc/dnsmasq.dhcpd/
|
||||||
sudo rm -f /etc/hostapd/hostapd.conf{.tpl,} /etc/radvd.conf{.tpl,} /etc/dhcp/dhcpd.conf{.tpl,}
|
sudo rm -f /etc/hostapd/hostapd.conf{.tpl?,}
|
||||||
sudo rm -f /etc/nginx/conf.d/${domain}.d/wifiadmin.conf
|
sudo rm -f /etc/nginx/conf.d/${domain}.d/wifiadmin.conf
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/wifiadmin.conf
|
sudo rm -f /etc/php5/fpm/pool.d/wifiadmin.conf
|
||||||
|
|
||||||
|
|
|
@ -77,12 +77,15 @@ function is_connected_through_hotspot($ip6_net, $ip4_nat_prefix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch('/', function() {
|
dispatch('/', function() {
|
||||||
exec('sudo iwconfig', $devs);
|
|
||||||
$wifi_device = moulinette_get('wifi_device');
|
|
||||||
$multissid = moulinette_get('multissid');
|
|
||||||
$ssids = array();
|
$ssids = array();
|
||||||
$devs_list = '';
|
$devs_list = '';
|
||||||
|
|
||||||
|
exec('sudo iwconfig', $devs);
|
||||||
|
|
||||||
|
$wifi_device = moulinette_get('wifi_device');
|
||||||
|
$multissid = moulinette_get('multissid');
|
||||||
|
$wifi_channel = moulinette_get('wifi_channel');
|
||||||
|
|
||||||
foreach($devs AS $dev) {
|
foreach($devs AS $dev) {
|
||||||
if(preg_match('/802.11/', $dev)) {
|
if(preg_match('/802.11/', $dev)) {
|
||||||
$dev = explode(' ', $dev);
|
$dev = explode(' ', $dev);
|
||||||
|
@ -96,7 +99,6 @@ dispatch('/', function() {
|
||||||
$wifi_ssid = getArray(moulinette_get('wifi_ssid'));
|
$wifi_ssid = getArray(moulinette_get('wifi_ssid'));
|
||||||
$wifi_secure = getArray(moulinette_get('wifi_secure'));
|
$wifi_secure = getArray(moulinette_get('wifi_secure'));
|
||||||
$wifi_passphrase = getArray(moulinette_get('wifi_passphrase'));
|
$wifi_passphrase = getArray(moulinette_get('wifi_passphrase'));
|
||||||
$wifi_channel = getArray(moulinette_get('wifi_channel'));
|
|
||||||
$ip6_net = getArray(moulinette_get('ip6_net'));
|
$ip6_net = getArray(moulinette_get('ip6_net'));
|
||||||
$ip6_dns0 = getArray(moulinette_get('ip6_dns0'));
|
$ip6_dns0 = getArray(moulinette_get('ip6_dns0'));
|
||||||
$ip6_dns1 = getArray(moulinette_get('ip6_dns1'));
|
$ip6_dns1 = getArray(moulinette_get('ip6_dns1'));
|
||||||
|
@ -110,7 +112,6 @@ dispatch('/', function() {
|
||||||
'wifi_ssid' => noneValue($wifi_ssid[$i]),
|
'wifi_ssid' => noneValue($wifi_ssid[$i]),
|
||||||
'wifi_secure' => noneValue($wifi_secure[$i]),
|
'wifi_secure' => noneValue($wifi_secure[$i]),
|
||||||
'wifi_passphrase' => noneValue($wifi_passphrase[$i]),
|
'wifi_passphrase' => noneValue($wifi_passphrase[$i]),
|
||||||
'wifi_channel' => noneValue($wifi_channel[$i]),
|
|
||||||
'ip6_net' => noneValue($ip6_net[$i]),
|
'ip6_net' => noneValue($ip6_net[$i]),
|
||||||
'ip6_dns0' => noneValue($ip6_dns0[$i]),
|
'ip6_dns0' => noneValue($ip6_dns0[$i]),
|
||||||
'ip6_dns1' => noneValue($ip6_dns1[$i]),
|
'ip6_dns1' => noneValue($ip6_dns1[$i]),
|
||||||
|
@ -129,6 +130,7 @@ dispatch('/', function() {
|
||||||
set('service_enabled', moulinette_get('service_enabled'));
|
set('service_enabled', moulinette_get('service_enabled'));
|
||||||
set('ssids', $ssids);
|
set('ssids', $ssids);
|
||||||
set('wifi_device', $wifi_device);
|
set('wifi_device', $wifi_device);
|
||||||
|
set('wifi_channel', $wifi_channel);
|
||||||
set('wifi_device_list', $devs_list);
|
set('wifi_device_list', $devs_list);
|
||||||
set('faststatus', service_faststatus() == 0);
|
set('faststatus', service_faststatus() == 0);
|
||||||
set('is_connected_through_hotspot', is_connected_through_hotspot($ip6_net, $ip4_nat_prefix));
|
set('is_connected_through_hotspot', is_connected_through_hotspot($ip6_net, $ip4_nat_prefix));
|
||||||
|
@ -157,8 +159,8 @@ dispatch_put('/settings', function() {
|
||||||
$ssid['wifi_passphrase'] = 'none';
|
$ssid['wifi_passphrase'] = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($ssid['wifi_ssid']) || empty($ssid['wifi_passphrase']) || empty($ssid['wifi_channel'])) {
|
if(empty($ssid['wifi_ssid']) || empty($ssid['wifi_passphrase'])) {
|
||||||
throw new Exception(T_('Your Wifi Hotspot needs a name, a password and a channel'));
|
throw new Exception(T_('Your Wifi Hotspot needs a name and a password'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ssid['wifi_secure'] && (strlen($ssid['wifi_passphrase']) < 8 || strlen($ssid['wifi_passphrase']) > 63)) {
|
if($ssid['wifi_secure'] && (strlen($ssid['wifi_passphrase']) < 8 || strlen($ssid['wifi_passphrase']) > 63)) {
|
||||||
|
@ -231,7 +233,7 @@ dispatch_put('/settings', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//stop_service();
|
stop_service();
|
||||||
|
|
||||||
moulinette_set('service_enabled', $service_enabled);
|
moulinette_set('service_enabled', $service_enabled);
|
||||||
$settings = array();
|
$settings = array();
|
||||||
|
@ -244,12 +246,14 @@ dispatch_put('/settings', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
moulinette_set('multissid', count($ssids));
|
moulinette_set('multissid', count($ssids));
|
||||||
|
moulinette_set('wifi_device', $_POST['wifi_device']);
|
||||||
|
moulinette_set('wifi_channel', $_POST['wifi_channel']);
|
||||||
|
|
||||||
foreach($settings as $setting => $value) {
|
foreach($settings as $setting => $value) {
|
||||||
moulinette_set($setting, preg_replace('/\|$/', '', $value));
|
moulinette_set($setting, preg_replace('/\|$/', '', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
//$retcode = start_service();
|
$retcode = start_service();
|
||||||
|
|
||||||
if($retcode == 0) {
|
if($retcode == 0) {
|
||||||
flash('success', T_('Configuration updated and service successfully reloaded'));
|
flash('success', T_('Configuration updated and service successfully reloaded'));
|
||||||
|
|
|
@ -34,29 +34,6 @@
|
||||||
<a class="btn input-group-addon wifiparty" data-toggle="tooltip" data-title="<?= T_('Show to your friends how to access to your hotspot') ?>"><span class="glyphicon glyphicon-fullscreen"></span></a>
|
<a class="btn input-group-addon wifiparty" data-toggle="tooltip" data-title="<?= T_('Show to your friends how to access to your hotspot') ?>"><span class="glyphicon glyphicon-fullscreen"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-3 control-label"><?= T_('Channel') ?></label>
|
|
||||||
<div class="col-sm-9 input-group-btn">
|
|
||||||
<div class="input-group dropdownmenu">
|
|
||||||
<input type="text" name="ssid[<?= $ssid['id'] ?>][wifi_channel]" value="<?= $ssid['wifi_channel'] ?>" style="display: none" />
|
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><?= $ssid['wifi_channel'] ?> <span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-left" role="menu">
|
|
||||||
<li <?= $ssid['wifi_channel'] == 1 ? 'class="active"' : '' ?>><a href="javascript:;">1</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 2 ? 'class="active"' : '' ?>><a href="javascript:;">2</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 3 ? 'class="active"' : '' ?>><a href="javascript:;">3</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 4 ? 'class="active"' : '' ?>><a href="javascript:;">4</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 5 ? 'class="active"' : '' ?>><a href="javascript:;">5</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 6 ? 'class="active"' : '' ?>><a href="javascript:;">6</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 7 ? 'class="active"' : '' ?>><a href="javascript:;">7</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 8 ? 'class="active"' : '' ?>><a href="javascript:;">8</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 9 ? 'class="active"' : '' ?>><a href="javascript:;">9</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 10 ? 'class="active"' : '' ?>><a href="javascript:;">10</a></li>
|
|
||||||
<li <?= $ssid['wifi_channel'] == 11 ? 'class="active"' : '' ?>><a href="javascript:;">11</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- IPv6 -->
|
<!-- IPv6 -->
|
||||||
|
|
|
@ -89,6 +89,28 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"><?= T_('Channel') ?></label>
|
||||||
|
<div class="col-sm-9 input-group-btn">
|
||||||
|
<div class="input-group dropdownmenu">
|
||||||
|
<input type="text" name="wifi_channel" value="<?= $wifi_channel ?>" style="display: none" />
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><?= $wifi_channel ?> <span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-left" role="menu">
|
||||||
|
<li <?= $wifi_channel == 1 ? 'class="active"' : '' ?>><a href="javascript:;">1</a></li>
|
||||||
|
<li <?= $wifi_channel == 2 ? 'class="active"' : '' ?>><a href="javascript:;">2</a></li>
|
||||||
|
<li <?= $wifi_channel == 3 ? 'class="active"' : '' ?>><a href="javascript:;">3</a></li>
|
||||||
|
<li <?= $wifi_channel == 4 ? 'class="active"' : '' ?>><a href="javascript:;">4</a></li>
|
||||||
|
<li <?= $wifi_channel == 5 ? 'class="active"' : '' ?>><a href="javascript:;">5</a></li>
|
||||||
|
<li <?= $wifi_channel == 6 ? 'class="active"' : '' ?>><a href="javascript:;">6</a></li>
|
||||||
|
<li <?= $wifi_channel == 7 ? 'class="active"' : '' ?>><a href="javascript:;">7</a></li>
|
||||||
|
<li <?= $wifi_channel == 8 ? 'class="active"' : '' ?>><a href="javascript:;">8</a></li>
|
||||||
|
<li <?= $wifi_channel == 9 ? 'class="active"' : '' ?>><a href="javascript:;">9</a></li>
|
||||||
|
<li <?= $wifi_channel == 10 ? 'class="active"' : '' ?>><a href="javascript:;">10</a></li>
|
||||||
|
<li <?= $wifi_channel == 11 ? 'class="active"' : '' ?>><a href="javascript:;">11</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue