mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
using new helpers and script formatting
This commit is contained in:
parent
b16eb19a34
commit
7cbd23c1ec
8 changed files with 316 additions and 177 deletions
|
@ -1,21 +1,32 @@
|
||||||
{
|
{
|
||||||
"name": "Wifi Hotspot",
|
"name": "Wifi Hotspot",
|
||||||
"id": "hotspot",
|
"id": "hotspot",
|
||||||
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Wifi Hotspot",
|
"en": "Wifi Hotspot",
|
||||||
"fr": "Hotspot Wifi"
|
"fr": "Hotspot Wifi"
|
||||||
},
|
},
|
||||||
"license": "AGPL-3",
|
"url": "https://github.com/labriqueinternet/hotspot_ynh",
|
||||||
"developer": {
|
"version": "1.1.0",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"maintainer": {
|
||||||
"name": "Julien Vaubourg",
|
"name": "Julien Vaubourg",
|
||||||
"email": "julien@vaubourg.com",
|
"email": "julien@vaubourg.com",
|
||||||
"url": "http://julien.vaubourg.com"
|
"url": "http://julien.vaubourg.com"
|
||||||
},
|
},
|
||||||
"multi_instance": "false",
|
"requirements": {
|
||||||
|
"yunohost": ">= 2.2.0",
|
||||||
|
"moulinette": ">= 2.4.0"
|
||||||
|
},
|
||||||
|
"multi_instance": false,
|
||||||
|
"services": [
|
||||||
|
"php5-fpm"
|
||||||
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
|
"type": "domain",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a domain for the web administration",
|
"en": "Choose a domain for the web administration",
|
||||||
"fr": "Choisissez un domaine pour l'administration web"
|
"fr": "Choisissez un domaine pour l'administration web"
|
||||||
|
@ -24,6 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
|
"type": "path",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a path for the web administration",
|
"en": "Choose a path for the web administration",
|
||||||
"fr": "Choisissez un chemin pour l'administration web"
|
"fr": "Choisissez un chemin pour l'administration web"
|
||||||
|
@ -42,6 +54,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "wifi_passphrase",
|
"name": "wifi_passphrase",
|
||||||
|
"type": "password",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a wifi password (at least 8 characters for WPA2)",
|
"en": "Choose a wifi password (at least 8 characters for WPA2)",
|
||||||
"fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)"
|
"fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)"
|
||||||
|
@ -50,6 +63,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "firmware_nonfree",
|
"name": "firmware_nonfree",
|
||||||
|
"choice": ["yes", "no"],
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)",
|
"en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)",
|
||||||
"fr": "Installer des firmwares non-libres (en plus des libres) pour la clé USB wifi (yes/no)"
|
"fr": "Installer des firmwares non-libres (en plus des libres) pour la clé USB wifi (yes/no)"
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
#
|
||||||
|
# Common variables
|
||||||
|
#
|
||||||
|
|
||||||
|
pkg_dependencies="php5-fpm sipcalc hostapd iptables iw dnsmasq"
|
||||||
|
nonfree_packages="firmware-linux-free firmware-linux-nonfree firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware zd1211-firmware"
|
||||||
|
free_packages="firmware-linux-free"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Helper to start/stop/.. a systemd service from a yunohost context,
|
# Helper to start/stop/.. a systemd service from a yunohost context,
|
||||||
# *and* the systemd service itself needs to be able to run yunohost
|
# *and* the systemd service itself needs to be able to run yunohost
|
||||||
# commands.
|
# commands.
|
||||||
#
|
#
|
||||||
# Hence the need to release the lock during the operation
|
# Hence the need to release the lock during the operation
|
||||||
#
|
#
|
||||||
# usage : ynh_systemctl yolo restart
|
# usage : ynh_systemctl yolo restart
|
||||||
|
@ -24,7 +30,7 @@ function ynh_systemctl()
|
||||||
# Save and release the lock...
|
# Save and release the lock...
|
||||||
cp $LOCKFILE $LOCKFILE.bkp.$$
|
cp $LOCKFILE $LOCKFILE.bkp.$$
|
||||||
rm $LOCKFILE
|
rm $LOCKFILE
|
||||||
|
|
||||||
# Wait for the end of the action
|
# Wait for the end of the action
|
||||||
wait $SYSCTLACTION
|
wait $SYSCTLACTION
|
||||||
|
|
|
@ -2,4 +2,18 @@
|
||||||
|
|
||||||
# nothing to do...
|
# nothing to do...
|
||||||
|
|
||||||
exit 0
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
281
scripts/install
281
scripts/install
|
@ -1,75 +1,130 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Wifi Hotspot app for YunoHost
|
# Wifi Hotspot app for YunoHost
|
||||||
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
||||||
# Contribute at https://github.com/labriqueinternet/hotspot_ynh
|
# Contribute at https://github.com/labriqueinternet/hotspot_ynh
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# 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
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# 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/>.
|
||||||
|
|
||||||
# This is an upgrade?
|
#=================================================
|
||||||
upgrade=$([ "${HOTSPOT_UPGRADE}" == 1 ] && echo true || echo false)
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=${1}
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
url_path=${2}
|
path_url=$YNH_APP_ARG_PATH
|
||||||
wifi_ssid=${3}
|
wifi_ssid=$YNH_APP_ARG_WIFI_SSID
|
||||||
wifi_passphrase=${4}
|
wifi_passphrase=$YNH_APP_ARG_WIFI_PASSPHRASE
|
||||||
firmware_nonfree=${5}
|
firmware_nonfree=$YNH_APP_ARG_FIRMWARE_NONFREE
|
||||||
|
|
||||||
if ! $upgrade; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
source ./helpers
|
#=================================================
|
||||||
source ./prerequisites
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Check arguments
|
# Check destination directory
|
||||||
if [ -z "${wifi_ssid}" -o -z "${wifi_passphrase}" ]; then
|
final_path="/var/www/$app"
|
||||||
echo "ERROR: Your Wifi Hotspot needs a name and a password" >&2
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
wifi_passphrase_length="$(echo -n "${wifi_passphrase}" | wc -c)"
|
|
||||||
if [ "${wifi_passphrase_length}" -lt 8 -o "${wifi_passphrase_length}" -gt 63 ]; then
|
|
||||||
echo "ERROR: Your password must from 8 to 63 characters (WPA2 passphrase)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${wifi_passphrase}" | grep -qP '[^[:print:]]'
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo "ERROR: Only printable ASCII characters are permitted in your password (WPA2 passphrase)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Normalize the url path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path "$path_url")
|
||||||
|
|
||||||
|
# Check web path availability
|
||||||
|
ynh_webpath_available "$domain" "$path_url"
|
||||||
|
# Register (book) web path
|
||||||
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
|
ynh_app_setting_set "$app" final_path "$final_path"
|
||||||
|
ynh_app_setting_set "$app" wifi_ssid "$wifi_ssid"
|
||||||
|
ynh_app_setting_set "$app" wifi_passphrase "$wifi_passphrase"
|
||||||
|
ynh_app_setting_set "$app" firmware_nonfree "$firmware_nonfree"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# RUN PREREQUISITES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source ./prerequisites
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK PARAMETERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Check arguments
|
||||||
|
if [[ -z $wifi_ssid || -z $wifi_passphrase ]]; then
|
||||||
|
ynh_die "Your Wifi Hotspot needs a name and a password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check domain/path availability
|
|
||||||
ynh_webpath_register hotspot $domain $url_path || exit 1
|
|
||||||
|
|
||||||
# Install packages
|
# Check passphrase length
|
||||||
packages='php5-fpm sipcalc hostapd iptables iw dnsmasq'
|
wifi_passphrase_length="$(echo -n "${wifi_passphrase}" | wc -c)"
|
||||||
|
if [[ $wifi_passphrase_length -lt 8 || $wifi_passphrase_length -gt 63 ]]; then
|
||||||
|
ynh_die "Your password must from 8 to 63 characters (WPA2 passphrase)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check no special characters are present in the passphrase
|
||||||
|
if [[ $wifi_passphrase =~ [^[:print:]] ]]; then
|
||||||
|
ynh_die "Only printable ASCII characters are permitted in your password (WPA2 passphrase)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL NONFREE FIRWARE IF REQUESTED
|
||||||
|
#=================================================
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Packaged USB Wireless Device firmwares
|
# Packaged USB Wireless Device firmwares
|
||||||
# Based on https://wiki.debian.org/WiFi#USB_Devices
|
# Based on https://wiki.debian.org/WiFi#USB_Devices
|
||||||
if [ "${firmware_nonfree}" == yes ]; then
|
if [[ $firmware_nonfree == yes ]]; then
|
||||||
# check if non-free is set on sources.list
|
# check if non-free is set on sources.list
|
||||||
if ! grep -q non-free /etc/apt/sources.list ; then
|
if ! grep -q non-free /etc/apt/sources.list ; then
|
||||||
sudo sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
|
sudo sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
|
||||||
fi
|
fi
|
||||||
|
|
||||||
packages="$packages firmware-linux-free firmware-linux-nonfree firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware zd1211-firmware"
|
packages=$nonfree_packages
|
||||||
else
|
else
|
||||||
packages="$packages firmware-linux-free"
|
packages=$free_packages
|
||||||
|
|
||||||
# Extract from http://packages.trisquel.info/toutatis-updates/open-ath9k-htc-firmware
|
# Extract from http://packages.trisquel.info/toutatis-updates/open-ath9k-htc-firmware
|
||||||
# https://www.fsf.org/news/ryf-certification-thinkpenguin-usb-with-atheros-chip
|
# https://www.fsf.org/news/ryf-certification-thinkpenguin-usb-with-atheros-chip
|
||||||
|
@ -80,66 +135,76 @@ fi
|
||||||
|
|
||||||
sudo apt-get --assume-yes --force-yes install ${packages}
|
sudo apt-get --assume-yes --force-yes install ${packages}
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get --assume-yes --force-yes install ${packages}
|
sudo apt-get --assume-yes --force-yes install ${packages}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $upgrade; then
|
#=================================================
|
||||||
|
# CHECK PARAMETERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Compute extra arguments
|
if [[ ! -v ip6_net ]]; then # if ip6_net not set
|
||||||
if [ -z "${ip6_net}" ]; then
|
ip6_net=none
|
||||||
ip6_net=none
|
ip6_addr=none
|
||||||
ip6_addr=none
|
|
||||||
|
if [[ -e /tmp/.ynh-vpnclient-started ]]; then
|
||||||
if [ -e /tmp/.ynh-vpnclient-started ]; then
|
vpnclient_ip6_net=$(sudo yunohost app setting vpnclient ip6_net 2>&1)
|
||||||
vpnclient_ip6_net=$(sudo yunohost app setting vpnclient ip6_net 2>&1)
|
vpnclient_ip6_addr=$(sudo yunohost app setting vpnclient ip6_addr 2>&1)
|
||||||
vpnclient_ip6_addr=$(sudo yunohost app setting vpnclient ip6_addr 2>&1)
|
|
||||||
|
if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then
|
||||||
if [[ "${vpnclient_ip6_net}" =~ :: && "${vpnclient_ip6_addr}" =~ :: ]]; then
|
ip6_net=${vpnclient_ip6_net}
|
||||||
ip6_net=${vpnclient_ip6_net}
|
ip6_addr=${vpnclient_ip6_addr}
|
||||||
ip6_addr=${vpnclient_ip6_addr}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wifi_device=$(sudo bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
|
||||||
|
|
||||||
# Save arguments
|
|
||||||
|
|
||||||
if [ -z "${wifi_device}" ]; then
|
|
||||||
sudo yunohost app setting hotspot service_enabled -v 0
|
|
||||||
wifi_device=none
|
|
||||||
else
|
|
||||||
sudo yunohost app setting hotspot service_enabled -v 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo yunohost app setting hotspot multissid -v 1
|
|
||||||
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_passphrase -v "${wifi_passphrase}"
|
|
||||||
sudo yunohost app setting hotspot wifi_device -v "${wifi_device}"
|
|
||||||
sudo yunohost app setting hotspot wifi_channel -v 6
|
|
||||||
sudo yunohost app setting hotspot ip6_addr -v "${ip6_addr}"
|
|
||||||
sudo yunohost app setting hotspot ip6_firewall -v 1
|
|
||||||
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_dns1 -v 2001:910:800::12
|
|
||||||
sudo yunohost app setting hotspot ip4_dns0 -v 80.67.188.188
|
|
||||||
sudo yunohost app setting hotspot ip4_dns1 -v 80.67.169.12
|
|
||||||
sudo yunohost app setting hotspot ip4_nat_prefix -v 10.0.242
|
|
||||||
sudo yunohost app setting hotspot vpnclient -v no
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install custom scripts
|
wifi_device=$(sudo bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
|
# Save arguments
|
||||||
|
|
||||||
|
if [[ -z $wifi_device ]]; then
|
||||||
|
ynh_app_setting_set $app service_enabled -v 0
|
||||||
|
wifi_device=none
|
||||||
|
else
|
||||||
|
ynh_app_setting_set $app service_enabled -v 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SAVE SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_app_setting_set $app multissid -v 1
|
||||||
|
ynh_app_setting_set $app wifi_ssid -v "${wifi_ssid}"
|
||||||
|
ynh_app_setting_set $app wifi_secure -v 1
|
||||||
|
ynh_app_setting_set $app wifi_passphrase -v "${wifi_passphrase}"
|
||||||
|
ynh_app_setting_set $app wifi_device -v "${wifi_device}"
|
||||||
|
ynh_app_setting_set $app wifi_channel -v 6
|
||||||
|
ynh_app_setting_set $app ip6_addr -v "${ip6_addr}"
|
||||||
|
ynh_app_setting_set $app ip6_firewall -v 1
|
||||||
|
ynh_app_setting_set $app ip6_net -v "${ip6_net}"
|
||||||
|
ynh_app_setting_set $app ip6_dns0 -v 2001:913::8
|
||||||
|
ynh_app_setting_set $app ip6_dns1 -v 2001:910:800::12
|
||||||
|
ynh_app_setting_set $app ip4_dns0 -v 80.67.188.188
|
||||||
|
ynh_app_setting_set $app ip4_dns1 -v 80.67.169.12
|
||||||
|
ynh_app_setting_set $app ip4_nat_prefix -v 10.0.242
|
||||||
|
ynh_app_setting_set $app vpnclient -v no
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL CUSTOM SCRIPTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo install -o root -g root -m 0755 ../conf/iw_multissid /usr/local/bin/
|
sudo install -o root -g root -m 0755 ../conf/iw_multissid /usr/local/bin/
|
||||||
sudo install -o root -g root -m 0755 ../conf/iw_devices /usr/local/bin/
|
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/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_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/ipv6_compressed /usr/local/bin/
|
||||||
|
|
||||||
# Copy confs
|
#=================================================
|
||||||
|
# COPY CONFIGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo mkdir -pm 0755 /var/log/nginx/
|
sudo mkdir -pm 0755 /var/log/nginx/
|
||||||
sudo mkdir -pm 0755 /etc/dnsmasq.dhcpd/
|
sudo mkdir -pm 0755 /etc/dnsmasq.dhcpd/
|
||||||
sudo chown root: /etc/dnsmasq.dhcpd/
|
sudo chown root: /etc/dnsmasq.dhcpd/
|
||||||
|
@ -150,7 +215,10 @@ sudo install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dn
|
||||||
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
|
||||||
|
|
||||||
# Copy web sources
|
#=================================================
|
||||||
|
# COPY WEB SOURCES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo mkdir -pm 0755 /var/www/wifiadmin/
|
sudo mkdir -pm 0755 /var/www/wifiadmin/
|
||||||
sudo cp -a ../sources/* /var/www/wifiadmin/
|
sudo cp -a ../sources/* /var/www/wifiadmin/
|
||||||
|
|
||||||
|
@ -158,12 +226,15 @@ sudo chown -R root: /var/www/wifiadmin/
|
||||||
sudo chmod -R 0644 /var/www/wifiadmin/*
|
sudo chmod -R 0644 /var/www/wifiadmin/*
|
||||||
sudo find /var/www/wifiadmin/ -type d -exec chmod +x {} \;
|
sudo find /var/www/wifiadmin/ -type d -exec chmod +x {} \;
|
||||||
|
|
||||||
# Fix confs
|
#=================================================
|
||||||
|
# FIX CONFIGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
## hostapd
|
## hostapd
|
||||||
sudo sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd
|
sudo sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd
|
||||||
|
|
||||||
## nginx
|
## nginx
|
||||||
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
||||||
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
||||||
sudo sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
sudo sed 's|<TPL:PHP_NAME>|wifiadmin|g' -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
|
||||||
|
|
||||||
|
@ -174,44 +245,42 @@ sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
|
||||||
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
|
sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/wifiadmin.conf
|
||||||
|
|
||||||
# Fix sources
|
# Fix sources
|
||||||
sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/wifiadmin/config.php
|
sudo sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i /var/www/wifiadmin/config.php
|
||||||
|
|
||||||
# Copy init script
|
# Copy init script
|
||||||
sudo install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/
|
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/
|
sudo install -o root -g root -m 0644 ../conf/ynh-hotspot.service /etc/systemd/system/
|
||||||
|
|
||||||
# Update firewall for DHCP
|
# Update firewall for DHCP
|
||||||
sudo yunohost firewall allow --no-upnp --ipv6 UDP 547
|
yunohost firewall allow --no-upnp --ipv6 UDP 547
|
||||||
sudo yunohost firewall allow --no-upnp UDP 67
|
yunohost firewall allow --no-upnp UDP 67
|
||||||
|
|
||||||
# Set default inits
|
# Set default inits
|
||||||
# The boot order of these services are important, so they are disabled by default
|
# The boot order of these services are important, so they are disabled by default
|
||||||
# and the ynh-hotspot service handles them.
|
# and the ynh-hotspot service handles them.
|
||||||
sudo systemctl disable hostapd
|
systemctl disable hostapd
|
||||||
sudo systemctl stop hostapd
|
systemctl stop hostapd
|
||||||
sudo systemctl enable php5-fpm
|
systemctl enable php5-fpm
|
||||||
sudo systemctl restart php5-fpm
|
systemctl restart php5-fpm
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
# Remove IPv6 address set if there is a VPN installed
|
# Remove IPv6 address set if there is a VPN installed
|
||||||
if [ "${ip6_addr}" != none ]; then
|
if [[ $ip6_addr != none ]]; then
|
||||||
sudo ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"
|
sudo ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"
|
||||||
if [ "$?" -eq 0 ]; then
|
if [[ "$?" -eq 0 ]]; then
|
||||||
sudo ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null
|
sudo ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl enable ynh-hotspot
|
systemctl enable ynh-hotspot
|
||||||
sudo yunohost service add ynh-hotspot
|
yunohost service add ynh-hotspot
|
||||||
|
|
||||||
if [ "${wifi_device}" == none ]; then
|
if [[ $wifi_device == none ]]; then
|
||||||
echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2
|
echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $upgrade; then
|
# start the app
|
||||||
ynh_systemctl start ynh-hotspot
|
ynh_systemctl start ynh-hotspot
|
||||||
fi
|
|
||||||
|
|
||||||
sudo yunohost app ssowatconf
|
# Reload SSOwat config
|
||||||
|
yunohost app ssowatconf
|
||||||
exit 0
|
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
# Source me
|
# Source me
|
||||||
|
|
||||||
# Check YunoHost version (dnsmasq)
|
# Check if dnsmasq is active
|
||||||
ynh_version=$(sudo dpkg -l yunohost | grep ii | awk '{ print $3 }' | sed 's/\.//g')
|
systemctl is-active dnsmasq &> /dev/null
|
||||||
|
|
||||||
if [ "${ynh_version}" -lt 220 ]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "ERROR: You need a YunoHost version equals or greater than 2.2.0" >&2
|
ynh_die "You need to enable dnsmasq instead of bind9 (apt-get remove bind9 && systemctl start dnsmasq)"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo systemctl is-active dnsmasq &> /dev/null
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: You need to enable dnsmasq instead of bind9 (apt-get remove bind9 && systemctl start dnsmasq)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,31 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Wifi Hotspot app for YunoHost
|
# Wifi Hotspot app for YunoHost
|
||||||
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
|
||||||
# Contribute at https://github.com/labriqueinternet/hotspot_ynh
|
# Contribute at https://github.com/labriqueinternet/hotspot_ynh
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# 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
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU Affero General Public License for more details.
|
# GNU Affero General Public License for more details.
|
||||||
#
|
#
|
||||||
# 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/>.
|
||||||
|
|
||||||
source ./helpers
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
source _common.sh
|
||||||
domain=$(sudo yunohost app setting hotspot domain)
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
firmware_nonfree=$(ynh_app_setting_get $app firmware_nonfree)
|
||||||
|
|
||||||
# The End
|
# The End
|
||||||
ynh_systemctl stop ynh-hotspot
|
systemctl stop ynh-hotspot
|
||||||
sudo systemctl disable ynh-hotspot
|
systemctl disable ynh-hotspot
|
||||||
sudo yunohost service remove ynh-hotspot
|
yunohost service remove ynh-hotspot
|
||||||
sudo rm -f /etc/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-*
|
sudo rm -f /tmp/.ynh-hotspot-*
|
||||||
|
|
||||||
|
@ -39,17 +52,23 @@ 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
|
||||||
|
|
||||||
# Remove free firmwares
|
# Remove packages
|
||||||
if ! dpkg -l firmware-atheros &> /dev/null; then
|
if [[ $firmware_nonfree == yes ]]; then
|
||||||
sudo rm -f /lib/firmware/htc_7010.fw
|
packages=$nonfree_packages
|
||||||
sudo rm -f /lib/firmware/htc_9271.fw
|
else
|
||||||
|
packages=$free_packages
|
||||||
|
|
||||||
|
# Remove free firmwares
|
||||||
|
if ! dpkg -l firmware-atheros &> /dev/null; then
|
||||||
|
sudo rm -f /lib/firmware/htc_7010.fw
|
||||||
|
sudo rm -f /lib/firmware/htc_9271.fw
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
sudo apt-get --assume-yes --force-yes remove ${packages}
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
sudo systemctl restart php5-fpm
|
systemctl restart php5-fpm
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
# Remove sources
|
# Remove sources
|
||||||
sudo rm -rf /var/www/wifiadmin/
|
sudo rm -rf /var/www/wifiadmin/
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
|
@ -1,5 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
gitcommit=$(sudo grep revision /etc/yunohost/apps/hotspot/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
|
gitcommit=$(sudo grep revision /etc/yunohost/apps/hotspot/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
|
||||||
tmpdir=$(mktemp -dp /tmp/ hotspot-restore-XXXXX)
|
tmpdir=$(mktemp -dp /tmp/ hotspot-restore-XXXXX)
|
||||||
|
|
||||||
|
@ -7,8 +25,6 @@ git clone https://github.com/labriqueinternet/hotspot_ynh.git "${tmpdir}/"
|
||||||
git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
|
git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
|
||||||
|
|
||||||
cd "${tmpdir}/scripts/"
|
cd "${tmpdir}/scripts/"
|
||||||
bash ./upgrade
|
bash ./upgrade
|
||||||
|
|
||||||
sudo rm -r "${tmpdir}/"
|
sudo rm -r "${tmpdir}/"
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
|
@ -1,46 +1,55 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ynh_setting() {
|
#=================================================
|
||||||
app=${1}
|
# GENERIC STARTING
|
||||||
setting=${2}
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
|
source _common.sh
|
||||||
}
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
domain=$(ynh_setting hotspot domain)
|
#=================================================
|
||||||
path=$(ynh_setting hotspot path)
|
# MANAGE SCRIPT FAILURE
|
||||||
wifi_ssid=$(ynh_setting hotspot wifi_ssid)
|
#=================================================
|
||||||
wifi_passphrase=$(ynh_setting hotspot wifi_passphrase)
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
wifi_ssid=$(ynh_app_setting_get $app wifi_ssid)
|
||||||
|
wifi_passphrase=$(ynh_app_setting_get $app wifi_passphrase)
|
||||||
|
firmware_nonfree=$(ynh_app_setting_get $app firmware_nonfree)
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
multissid=$(ynh_app_setting_get $app multissid)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK THE PATH
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Normalize the URL path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
source ./helpers
|
|
||||||
source ./prerequisites
|
source ./prerequisites
|
||||||
|
|
||||||
if dpkg -l firmware-linux-nonfree &> /dev/null; then
|
|
||||||
firmware_nonfree=yes
|
|
||||||
else
|
|
||||||
firmware_nonfree=no
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmpdir=$(mktemp -dp /tmp/ hotspot-upgrade-XXXXX)
|
|
||||||
sudo cp -a /etc/yunohost/apps/hotspot/settings.yml "${tmpdir}/"
|
|
||||||
|
|
||||||
export HOTSPOT_UPGRADE=1
|
|
||||||
sudo bash /etc/yunohost/apps/hotspot/scripts/remove &> /dev/null
|
|
||||||
bash ./install "${domain}" "${path}" "${wifi_ssid}" "${wifi_passphrase}" "${firmware_nonfree}"
|
|
||||||
|
|
||||||
sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/hotspot/
|
|
||||||
sudo rm -r "${tmpdir}/"
|
|
||||||
|
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
if [ -z "$(ynh_setting hotspot ip6_firewall)" ]; then
|
if [[ -z $(ynh_app_setting_get $app ip6_firewall) ]]; then
|
||||||
multissid=$(ynh_setting hotspot multissid)
|
|
||||||
ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
|
ip6_firewall=$(printf '1|%.0s' $(seq "${multissid}"))
|
||||||
ip6_firewall=$(echo "${ip6_firewall%?}")
|
ip6_firewall=$(echo "${ip6_firewall%?}")
|
||||||
|
|
||||||
sudo yunohost app setting hotspot ip6_firewall -v "${ip6_firewall}"
|
ynh_app_setting_set "${app}" ip6_firewall -v "${ip6_firewall}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_systemctl start ynh-hotspot
|
ynh_systemctl start ynh-hotspot
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
Loading…
Reference in a new issue