mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
jpp des tpl
This commit is contained in:
parent
017c6dec05
commit
3ad8d0fa69
5 changed files with 31 additions and 64 deletions
|
@ -1,25 +1,10 @@
|
||||||
# Wifi Hotspot app for YunoHost
|
# Wifi Hotspot app for YunoHost
|
||||||
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
|
||||||
# Contribute at https://github.com/labriqueinternet/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.
|
# Do DHCP for this subnet.
|
||||||
dhcp-range=interface:<TPL:WIFI_DEVICE>,<TPL:IP4_NAT_PREFIX>.2,<TPL:IP4_NAT_PREFIX>.254,4h
|
dhcp-range=interface:__WIFI_DEVICE__,__IP4_NAT_PREFIX__.2,__IP4_NAT_PREFIX__.254,4h
|
||||||
|
|
||||||
# Send DHCPv4 option.
|
# Send DHCPv4 option.
|
||||||
dhcp-option=option:dns-server,<TPL:IP4_DNS>
|
dhcp-option=option:dns-server,__IP4_DNS__
|
||||||
|
|
||||||
# Set the DHCP server to authoritative mode. In this mode it will barge in
|
# 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,
|
# and take over the lease for any client which broadcasts on the network,
|
||||||
|
|
|
@ -1,23 +1,6 @@
|
||||||
# Wifi Hotspot app for YunoHost
|
|
||||||
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
|
||||||
# Contribute at https://github.com/labriqueinternet/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
|
# 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.
|
# so that clients can use SLAAC addresses as well as DHCP ones.
|
||||||
dhcp-range=interface:<TPL:WIFI_DEVICE>,<TPL:IP6_NET>,slaac,64,4h
|
dhcp-range=interface:__WIFI_DEVICE__,__IP6_NET__,slaac,64,4h
|
||||||
|
|
||||||
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
# Send DHCPv6 option. Note [] around IPv6 addresses.
|
||||||
dhcp-option=option6:dns-server,<TPL:IP6_DNS>
|
dhcp-option=option6:dns-server,__IP6_DNS__
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
interface=<TPL:WIFI_DEVICE>
|
interface=__WIFI_DEVICE__
|
||||||
hw_mode=g
|
hw_mode=g
|
||||||
<TPL:N_COMMENT>ieee80211n=1
|
__N_COMMENT__ieee80211n=1
|
||||||
<TPL:N_COMMENT>wmm_enabled=1
|
__N_COMMENT__wmm_enabled=1
|
||||||
macaddr_acl=0
|
macaddr_acl=0
|
||||||
auth_algs=1
|
auth_algs=1
|
||||||
ignore_broadcast_ssid=0
|
ignore_broadcast_ssid=0
|
||||||
channel=<TPL:WIFI_CHANNEL>
|
channel=__WIFI_CHANNEL__
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<TPL:BSS_COMMENT>bss=<TPL:WIFI_INTERFACE>
|
__BSS_COMMENT__bss=__WIFI_INTERFACE__
|
||||||
ssid=<TPL:WIFI_SSID>
|
ssid=__WIFI_SSID__
|
||||||
<TPL:SEC_COMMENT>wpa=2
|
__SEC_COMMENT__wpa=2
|
||||||
<TPL:SEC_COMMENT>wpa_passphrase=<TPL:WIFI_PASSPHRASE>
|
__SEC_COMMENT__wpa_passphrase=__WIFI_PASSPHRASE__
|
||||||
<TPL:SEC_COMMENT>wpa_key_mgmt=WPA-PSK
|
__SEC_COMMENT__wpa_key_mgmt=WPA-PSK
|
||||||
<TPL:SEC_COMMENT>wpa_pairwise=TKIP
|
__SEC_COMMENT__wpa_pairwise=TKIP
|
||||||
<TPL:SEC_COMMENT>rsn_pairwise=CCMP
|
__SEC_COMMENT__rsn_pairwise=CCMP
|
||||||
|
|
||||||
|
|
|
@ -144,9 +144,9 @@ start_dhcpd6() {
|
||||||
|
|
||||||
cp /etc/dnsmasq.dhcpd/dhcpdv6{.conf.tpl,-ssid${i}.conf}
|
cp /etc/dnsmasq.dhcpd/dhcpdv6{.conf.tpl,-ssid${i}.conf}
|
||||||
|
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
sed "s|__WIFI_DEVICE__|${dev}|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|__IP6_NET__|${ynh_ip6_net[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
sed "s|<TPL:IP6_DNS>|${ynh_ip6_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
sed "s|__IP6_DNS__|${ynh_ip6_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||||
|
|
||||||
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf -p0
|
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf -p0
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,9 @@ start_dhcpd4() {
|
||||||
|
|
||||||
cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
|
cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
|
||||||
|
|
||||||
sed "s|<TPL:IP4_DNS>|${ynh_ip4_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
sed "s|__IP4_DNS__|${ynh_ip4_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
sed "s|__WIFI_DEVICE__|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||||
sed "s|<TPL:IP4_NAT_PREFIX>|${ynh_ip4_nat_prefix[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
sed "s|__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
|
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
|
||||||
}
|
}
|
||||||
|
@ -170,27 +170,27 @@ start_hostapd() {
|
||||||
ethaddr=$(ip link show dev "${ynh_wifi_device}" | grep link/ether | awk -F: '{ printf "02:%s:%s:%s:%s:00", $2, $3, $4, $5 }')
|
ethaddr=$(ip link show dev "${ynh_wifi_device}" | grep link/ether | awk -F: '{ printf "02:%s:%s:%s:%s:00", $2, $3, $4, $5 }')
|
||||||
ip link set addr "${ethaddr}" dev "${ynh_wifi_device}"
|
ip link set addr "${ethaddr}" dev "${ynh_wifi_device}"
|
||||||
|
|
||||||
sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/hostapd/hostapd.conf
|
sed "s|__WIFI_DEVICE__|${ynh_wifi_device}|g" -i /etc/hostapd/hostapd.conf
|
||||||
sed "s|<TPL:WIFI_CHANNEL>|${ynh_wifi_channel}|g" -i /etc/hostapd/hostapd.conf
|
sed "s|__WIFI_CHANNEL__|${ynh_wifi_channel}|g" -i /etc/hostapd/hostapd.conf
|
||||||
sed "s|<TPL:N_COMMENT>||g" -i /etc/hostapd/hostapd.conf
|
sed "s|__N_COMMENT__||g" -i /etc/hostapd/hostapd.conf
|
||||||
|
|
||||||
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||||
cp /etc/hostapd/hostapd.conf{.tpl2,.tmp}
|
cp /etc/hostapd/hostapd.conf{.tpl2,.tmp}
|
||||||
|
|
||||||
sed "s|<TPL:WIFI_INTERFACE>|hotspot${i}|g" -i /etc/hostapd/hostapd.conf.tmp
|
sed "s|__WIFI_INTERFACE__|hotspot${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|__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
|
sed "s|__WIFI_PASSPHRASE__|${ynh_wifi_passphrase[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
|
|
||||||
if [ "${ynh_wifi_secure[${i}]}" -eq 1 ]; then
|
if [ "${ynh_wifi_secure[${i}]}" -eq 1 ]; then
|
||||||
sed "s|<TPL:SEC_COMMENT>||g" -i /etc/hostapd/hostapd.conf.tmp
|
sed "s|__SEC_COMMENT__||g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
else
|
else
|
||||||
sed "s|<TPL:SEC_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
sed "s|__SEC_COMMENT__|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${i}" -eq 0 ]; then
|
if [ "${i}" -eq 0 ]; then
|
||||||
sed "s|<TPL:BSS_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
sed "s|__BSS_COMMENT__|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
else
|
else
|
||||||
sed "s|<TPL:BSS_COMMENT>||g" -i /etc/hostapd/hostapd.conf.tmp
|
sed "s|__BSS_COMMENT__||g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
|
cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
|
||||||
|
|
Loading…
Reference in a new issue