mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Improve templating seds etc
This commit is contained in:
parent
97a1c737ea
commit
00fd220f15
4 changed files with 17 additions and 43 deletions
8
conf/hostapd.base.conf
Normal file
8
conf/hostapd.base.conf
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
interface=__WIFI_DEVICE__
|
||||||
|
hw_mode=g
|
||||||
|
__N_COMMENT__ieee80211n=1
|
||||||
|
__N_COMMENT__wmm_enabled=1
|
||||||
|
macaddr_acl=0
|
||||||
|
auth_algs=1
|
||||||
|
ignore_broadcast_ssid=0
|
||||||
|
channel=__WIFI_CHANNEL__
|
|
@ -1,26 +0,0 @@
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
interface=__WIFI_DEVICE__
|
|
||||||
hw_mode=g
|
|
||||||
__N_COMMENT__ieee80211n=1
|
|
||||||
__N_COMMENT__wmm_enabled=1
|
|
||||||
macaddr_acl=0
|
|
||||||
auth_algs=1
|
|
||||||
ignore_broadcast_ssid=0
|
|
||||||
channel=__WIFI_CHANNEL__
|
|
||||||
|
|
|
@ -164,40 +164,32 @@ start_dhcpd4() {
|
||||||
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
|
dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
|
||||||
}
|
}
|
||||||
|
|
||||||
start_hostapd() {
|
configure_hostapd() {
|
||||||
cp /etc/hostapd/hostapd.conf{.tpl1,}
|
|
||||||
|
|
||||||
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}"
|
||||||
|
|
||||||
|
cp /etc/hostapd/hostapd.base.conf /etc/hostapd/hostapd.conf
|
||||||
sed "s|__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|__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|__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}
|
|
||||||
|
[ "${ynh_wifi_secure[${i}]}" -eq 1 ] && local sec_comment="" || local sec_comment="#"
|
||||||
|
[ "${i}" -eq 0 ] && local bss_comment="#" || local bss_comment=""
|
||||||
|
|
||||||
|
cp /etc/hostapd/hostapd.accesspoint.conf /etc/hostapd/hostapd.conf.tmp
|
||||||
|
|
||||||
sed "s|__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|__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|__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
|
||||||
|
sed "s|__SEC_COMMENT__|${sec_comment}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
if [ "${ynh_wifi_secure[${i}]}" -eq 1 ]; then
|
sed "s|__BSS_COMMENT__|${bss_comment}|g" -i /etc/hostapd/hostapd.conf.tmp
|
||||||
sed "s|__SEC_COMMENT__||g" -i /etc/hostapd/hostapd.conf.tmp
|
|
||||||
else
|
|
||||||
sed "s|__SEC_COMMENT__|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${i}" -eq 0 ]; then
|
|
||||||
sed "s|__BSS_COMMENT__|#|g" -i /etc/hostapd/hostapd.conf.tmp
|
|
||||||
else
|
|
||||||
sed "s|__BSS_COMMENT__||g" -i /etc/hostapd/hostapd.conf.tmp
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
|
cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
|
||||||
rm /etc/hostapd/hostapd.conf.tmp
|
rm /etc/hostapd/hostapd.conf.tmp
|
||||||
done
|
done
|
||||||
|
|
||||||
systemctl start hostapd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## Unsetters
|
## Unsetters
|
||||||
|
|
Loading…
Add table
Reference in a new issue