mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Ready for Jessie (+ some improvements)
This commit is contained in:
parent
f7187c4c43
commit
e15fb76389
8 changed files with 62 additions and 61 deletions
|
@ -43,10 +43,5 @@ In this manner, with this example, you can provide 3 access points at the same t
|
|||
|
||||
## Prerequisites
|
||||
|
||||
This app works with a non-stable version of YunoHost.
|
||||
|
||||
Until this version is available (coming soon!) as an official stable release, you need to execute some commands before installing this app:
|
||||
|
||||
# systemctl stop bind9
|
||||
# systemctl disable bind9
|
||||
# apt-get install dnsmasq
|
||||
* Debian Jessie
|
||||
* YunoHost >= 2.2.0
|
||||
|
|
|
@ -18,5 +18,10 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
phy=$(iw "${1}" info | grep wiphy | awk '{ print $NF }')
|
||||
multissid=$(iw "phy${phy}" info | grep -A1 'valid interface combinations' | tail -n1 | sed 's/.*{.*AP.*}\s<=\s\(.*\),.*/\1/')
|
||||
|
||||
iw "phy${phy}" info | grep -A1 'valid interface combinations' | tail -n1 | sed 's/.*{.*AP.*}\s<=\s\(.*\),.*/\1/'
|
||||
if [ -z "${multissid}" ]; then
|
||||
echo 1
|
||||
else
|
||||
echo $multissid
|
||||
fi
|
||||
|
|
|
@ -80,13 +80,13 @@ is_dhcpd4_running() {
|
|||
}
|
||||
|
||||
is_hostapd_running() {
|
||||
systemctl is-active hostapd --quiet &> /dev/null
|
||||
systemctl is-active hostapd &> /dev/null
|
||||
}
|
||||
|
||||
is_running() {
|
||||
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||
( has_ip6delegatedprefix ${i} && is_ip6addr_set ${i} || ! has_ip6delegatedprefix ${i} )\
|
||||
&& is_ip4nataddr_set ${i} && is_dhcpd6_running ${i} && is_dhcpd4_running ${i}
|
||||
( has_ip6delegatedprefix ${i} && is_ip6addr_set ${i} && is_dhcpd6_running ${i} || ! has_ip6delegatedprefix ${i} )\
|
||||
&& is_ip4nataddr_set ${i} && is_dhcpd4_running ${i}
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
return 1
|
||||
|
@ -143,9 +143,7 @@ start_dhcpd6() {
|
|||
dev="hotspot${i}"
|
||||
fi
|
||||
|
||||
rm -f /etc/dnsmasq.dhcpd/dhcpdv6-ssid*.conf
|
||||
|
||||
cp /etc/dnsmasq.dhcp/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|<TPL:IP6_NET>|${ynh_ip6_net[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
|
||||
|
@ -164,8 +162,6 @@ start_dhcpd4() {
|
|||
dev="hotspot${i}"
|
||||
fi
|
||||
|
||||
rm -f /etc/dnsmasq.dhcpd/dhcpdv4-ssid*.conf
|
||||
|
||||
cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
|
||||
|
||||
sed "s|<TPL:IP4_DNS0>|${ynh_ip4_dns0[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
|
||||
|
@ -209,7 +205,7 @@ start_hostapd() {
|
|||
rm /etc/hostapd/hostapd.conf.tmp
|
||||
done
|
||||
|
||||
systemctl start hostapd --quiet
|
||||
systemctl start hostapd
|
||||
}
|
||||
|
||||
## Unsetters
|
||||
|
@ -260,33 +256,41 @@ stop_dhcpd4() {
|
|||
}
|
||||
|
||||
stop_hostapd() {
|
||||
systemctl stop hostapd --quiet
|
||||
systemctl stop hostapd
|
||||
}
|
||||
|
||||
## Tools
|
||||
|
||||
moulinette_get() {
|
||||
var=${1}
|
||||
gotcha=0
|
||||
|
||||
while [ "${gotcha}" -eq 0 ]; do
|
||||
value=$(yunohost app setting hotspot "${var}")
|
||||
|
||||
if [[ "${value}" =~ "An instance is already running" ]]; then
|
||||
echo "${value}" >&2
|
||||
exit 1
|
||||
sleep $(($((RANDOM%5)) + 1))
|
||||
else
|
||||
gotcha=1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${value}"
|
||||
}
|
||||
|
||||
moulinette_vpnclient_get() {
|
||||
var=${1}
|
||||
gotcha=0
|
||||
|
||||
while [ "${gotcha}" -eq 0 ]; do
|
||||
value=$(yunohost app setting vpnclient "${var}")
|
||||
|
||||
if [[ "${value}" =~ "An instance is already running" ]]; then
|
||||
echo "${value}" >&2
|
||||
exit 1
|
||||
sleep $(($((RANDOM%5)) + 1))
|
||||
else
|
||||
gotcha=1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${value}"
|
||||
}
|
||||
|
@ -308,7 +312,7 @@ if [ "$1" != restart ]; then
|
|||
# Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
|
||||
if [ ! -e /tmp/.ynh-hotspot-boot ]; then
|
||||
touch /tmp/.ynh-hotspot-boot
|
||||
systemctl restart php5-fpm --quiet
|
||||
systemctl restart php5-fpm
|
||||
fi
|
||||
|
||||
# Variables
|
||||
|
@ -407,12 +411,16 @@ case "$1" in
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${ynh_multissid}" -gt 1 ]; then
|
||||
i=0; false || while [ $? -ne 0 ]; do
|
||||
sleep 1 && (( i++ ))
|
||||
[ ${i} -gt 20 ] && stop_hostapd
|
||||
[ ${i} -gt 20 ] && exit 1
|
||||
ip link show dev "mon.${ynh_wifi_device}" &> /dev/null
|
||||
ip link show dev hotspot1 &> /dev/null
|
||||
done
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# For each registred ssid
|
||||
|
@ -489,8 +497,9 @@ case "$1" in
|
|||
stop_hostapd
|
||||
fi
|
||||
|
||||
# Fix configuration
|
||||
if has_vpnclient_app; then
|
||||
systemctl start ynh-vpnclient --quiet
|
||||
ynh-vpnclient start
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
|
|
|
@ -6,10 +6,8 @@ After=network.target
|
|||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/ynh-hotspot start
|
||||
ExecRestart=/usr/local/bin/ynh-hotspot restart
|
||||
ExecStop=/usr/local/bin/ynh-hotspot stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=ynh-hotspot.service
|
||||
|
|
|
@ -39,10 +39,10 @@ if [ "${ynh_version}" -lt 220 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
sudo systemctl status dnsmasq status --quiet &> /dev/null
|
||||
sudo systemctl is-active dnsmasq &> /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: You need to enable dnsmasq instead of bind9 (apt-get remove bind && systemctl start dnsmasq)"
|
||||
echo "ERROR: You need to enable dnsmasq instead of bind9 (apt-get remove bind9 && systemctl start dnsmasq)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -152,7 +152,6 @@ sudo install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/
|
|||
sudo install -o root -g root -m 0755 ../conf/iw_ssids /usr/local/bin/
|
||||
sudo install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/
|
||||
sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
|
||||
sudo install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/
|
||||
|
||||
# Copy confs
|
||||
sudo mkdir -pm 0755 /var/log/nginx/
|
||||
|
@ -192,7 +191,8 @@ sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/
|
|||
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/wifiadmin/config.php
|
||||
|
||||
# Copy init script
|
||||
sudo install -o root -g root -m 0755 ../conf/ynh-hotspot.service /lib/systemd/system/ynh-hotspot.service
|
||||
sudo install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/
|
||||
sudo install -o root -g root -m 0644 ../conf/ynh-hotspot.service /etc/systemd/system/
|
||||
|
||||
# Update firewall for DHCP
|
||||
sudo yunohost firewall allow --no-upnp --ipv6 UDP 547
|
||||
|
@ -201,15 +201,13 @@ sudo yunohost firewall allow --no-upnp UDP 67
|
|||
# Set default inits
|
||||
# The boot order of these services are important, so they are disabled by default
|
||||
# and the ynh-hotspot service handles them.
|
||||
# All services are registred by yunohost in order to prevent conflicts after the uninstall.
|
||||
sudo yunohost service add hostapd
|
||||
sudo yunohost service stop hostapd
|
||||
sudo yunohost service disable hostapd
|
||||
sudo systemctl disable hostapd
|
||||
sudo systemctl stop hostapd
|
||||
|
||||
sudo yunohost service add php5-fpm
|
||||
sudo yunohost service enable php5-fpm
|
||||
sudo systemctl enable php5-fpm
|
||||
sudo systemctl restart php5-fpm
|
||||
|
||||
sudo systemcld reload nginx
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Remove IPv6 address set if there is a VPN installed
|
||||
if [ "${ip6_addr}" != none ]; then
|
||||
|
@ -219,10 +217,8 @@ if [ "${ip6_addr}" != none ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
sudo yunohost service add ynh-hotspot
|
||||
sudo yunohost service enable ynh-hotspot
|
||||
sudo systemctl reenable ynh-hotspot
|
||||
sudo systemcld start ynh-hotspot
|
||||
sudo systemctl enable ynh-hotspot
|
||||
sudo systemctl start ynh-hotspot
|
||||
|
||||
# Update SSO for wifiadmin
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -22,9 +22,8 @@ domain=$(sudo yunohost app setting hotspot domain)
|
|||
|
||||
# The End
|
||||
sudo systemctl stop ynh-hotspot
|
||||
sudo yunohost service remove ynh-hotspot
|
||||
sudo systemctl disable ynh-hotspot
|
||||
sudo rm -f /lib/systemd/system/ynh-hotspot.service /usr/local/bin/ynh-hotspot
|
||||
sudo rm -f /etc/systemd/system/ynh-hotspot.service /usr/local/bin/ynh-hotspot
|
||||
sudo rm -f /tmp/.ynh-hotspot-*
|
||||
|
||||
# Update firewall for DHCP
|
||||
|
@ -42,8 +41,7 @@ sudo rm -f /lib/firmware/htc-7010.fw
|
|||
sudo rm -f /lib/firmware/htc-9271.fw
|
||||
|
||||
# Restart services
|
||||
sudo yunohost service stop php5-fpm
|
||||
sudo yunohost service start php5-fpm
|
||||
sudo systemctl restart php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Remove sources
|
||||
|
|
|
@ -37,7 +37,7 @@ function start_service() {
|
|||
}
|
||||
|
||||
function service_status() {
|
||||
exec('sudo systemctl is-active ynh-hotspot', $output);
|
||||
exec('sudo ynh-hotspot status', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ dispatch('/', function() {
|
|||
}
|
||||
|
||||
$ip6_net = moulinette_get('ip6_net');
|
||||
$ip6_net = ($ip6_net == 'none') ? '' : $ip6_net;
|
||||
$ip4_nat_prefix = moulinette_get('ip4_nat_prefix');
|
||||
$ip6_net = ($ip6_net == 'none') ? '' : getArray($ip6_net);
|
||||
$ip4_nat_prefix = getArray(moulinette_get('ip4_nat_prefix'));
|
||||
|
||||
set('service_enabled', moulinette_get('service_enabled'));
|
||||
set('ssids', $ssids);
|
||||
|
|
|
@ -66,7 +66,7 @@ div#saveconfirmation {
|
|||
display: none;
|
||||
padding-right: 15px;
|
||||
width: 60%;
|
||||
margin: 0 auto;
|
||||
margin: 15px auto 0;
|
||||
}
|
||||
|
||||
div#saveconfirmation div#confirm {
|
||||
|
|
Loading…
Reference in a new issue