mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
commit
7eea610de4
11 changed files with 55 additions and 77 deletions
Binary file not shown.
Binary file not shown.
|
@ -1,10 +1,11 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=YunoHost Wifi Hotspot.
|
Description=YunoHost Wifi Hotspot
|
||||||
Requires=network.target
|
Requires=network.target
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
User=root
|
||||||
ExecStart=/usr/local/bin/ynh-hotspot start
|
ExecStart=/usr/local/bin/ynh-hotspot start
|
||||||
ExecStop=/usr/local/bin/ynh-hotspot stop
|
ExecStop=/usr/local/bin/ynh-hotspot stop
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"id": "hotspot",
|
"id": "hotspot",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Wifi Hotspot",
|
"en": "Create and manager wifi networks, share Internet access and use Yunohost apps accross wifi",
|
||||||
"fr": "Hotspot Wifi"
|
"fr": "Créer et configurer des réseaux wifi, partager l'accès a Internet et utiliser les applications Yunohost via wifi"
|
||||||
},
|
},
|
||||||
"url": "https://github.com/labriqueinternet/hotspot_ynh",
|
"url": "https://github.com/labriqueinternet/hotspot_ynh",
|
||||||
"version": "1.2.0~ynh3",
|
"version": "1.2.0~ynh3",
|
||||||
|
@ -27,20 +27,11 @@
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for the web administration",
|
|
||||||
"fr": "Choisissez un domaine pour l'administration web"
|
|
||||||
},
|
|
||||||
"example": "domain.org"
|
"example": "domain.org"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for the web administration",
|
|
||||||
"fr": "Choisissez un chemin pour l'administration web"
|
|
||||||
},
|
|
||||||
"example": "/wifiadmin",
|
|
||||||
"default": "/wifiadmin"
|
"default": "/wifiadmin"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,44 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
pkg_dependencies="sipcalc hostapd iptables iw dnsmasq"
|
pkg_dependencies="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"
|
nonfree_firmware_packages="firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211"
|
||||||
free_packages="firmware-linux-free"
|
free_firmware_packages="firmware-ath9k-htc"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
function check_armbian_nonfree_conflict()
|
||||||
|
{
|
||||||
|
|
||||||
|
# If we're on armbian, force $firmware_nonfree
|
||||||
|
# because armbian-firmware conflicts with firmware-misc-nonfree package
|
||||||
|
if dpkg --list | grep -q armbian-firmware; then
|
||||||
|
echo "You are running Armbian and firmware-misc-nonfree are known to conflict with armbian-firwmare. " >&2
|
||||||
|
echo "The package firmware-misc-nonfree is a dependency of firmware-ralink, so firmware-ralink will NOT be installed" >&2
|
||||||
|
echo "You can manually install firmware-ralink with 'apt -o Dpkg::Options::=\"--force-overwrite\" firmware-ralink'" >&2
|
||||||
|
nonfree_firmware_packages=$(echo $nonfree_firmware_packages | sed 's/ firmware-ralink//')
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hot_reload_usb_wifi_cards()
|
||||||
|
{
|
||||||
|
modulesList="acx-mac80211 ar5523 ar9170usb at76c50x-usb at76_usb ath9k_htc carl9170 orinoco_usb p54usb prism2_usb r8712u r8192s_usb r8192u_usb rndis_wlan rt2500usb rt2800usb rt2870sta rt73usb rtl8187 rtl8192cu usb8xxx vt6656_stage zd1201 zd1211rw"
|
||||||
|
modprobe --quiet --remove $modulesList || true
|
||||||
|
possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq)
|
||||||
|
for usbPath in $possibleUsbDevicesNeedingReload; do
|
||||||
|
if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then
|
||||||
|
echo "Try to reload driver for usb $usbPath" >&2
|
||||||
|
echo 0 > /sys/bus/usb/devices/$usbPath/authorized
|
||||||
|
echo 1 > /sys/bus/usb/devices/$usbPath/authorized
|
||||||
|
# Wait for driver reloading
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -41,11 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
if [[ $firmware_nonfree -eq 0 ]]; then
|
|
||||||
ynh_backup --src_path="/lib/firmware/htc_7010.fw"
|
|
||||||
ynh_backup --src_path="/lib/firmware/htc_9271.fw"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/sudoers.d/${app}_ynh"
|
ynh_backup --src_path="/etc/sudoers.d/${app}_ynh"
|
||||||
|
|
||||||
ynh_backup --src_path="/usr/local/bin/iw_multissid"
|
ynh_backup --src_path="/usr/local/bin/iw_multissid"
|
||||||
|
|
|
@ -59,14 +59,6 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
# If we're on armbian, force $firmware_nonfree
|
|
||||||
# because armbian-firmware conflicts with the non-free packages ...
|
|
||||||
if dpkg --list | grep -q armbian-firmware; then
|
|
||||||
echo "You are running Armbian and non-free firmware are known to conflict with armbian-firwmare. " >&2
|
|
||||||
firmware_nonfree=0
|
|
||||||
echo "Variable firmware_non_free has been forced to 'no'" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $firmware_nonfree = "no" ]; then
|
if [ $firmware_nonfree = "no" ]; then
|
||||||
firmware_nonfree=0
|
firmware_nonfree=0
|
||||||
elif [ $firmware_nonfree = "yes" ]; then
|
elif [ $firmware_nonfree = "yes" ]; then
|
||||||
|
@ -121,19 +113,10 @@ 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 -eq 1 ]]; then
|
if [[ $firmware_nonfree -eq 1 ]]; then
|
||||||
# check if non-free is set on sources.list
|
check_armbian_nonfree_conflict
|
||||||
if ! grep -q non-free /etc/apt/sources.list ; then
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
|
||||||
sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
|
|
||||||
fi
|
|
||||||
packages=$nonfree_packages
|
|
||||||
else
|
else
|
||||||
packages=$free_packages
|
pkg_dependencies="$pkg_dependencies $free_firmware_packages"
|
||||||
# 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://wiki.debian.org/ath9k_htc/open_firmware
|
|
||||||
mkdir -p /lib/firmware
|
|
||||||
install -b -o root -g root -m 0644 ../conf/firmware_htc-7010.fw /lib/firmware/htc_7010.fw
|
|
||||||
install -b -o root -g root -m 0644 ../conf/firmware_htc-9271.fw /lib/firmware/htc_9271.fw
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -141,7 +124,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies"
|
ynh_script_progression --message="Installing dependencies"
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies" "$packages"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -181,6 +164,7 @@ if [[ ! -v ip6_net ]]; then # if ip6_net not set
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
hot_reload_usb_wifi_cards
|
||||||
wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=multissid --value=1
|
ynh_app_setting_set --app=$app --key=multissid --value=1
|
||||||
|
@ -263,8 +247,8 @@ ynh_replace_string --match_string="^DAEMON_CONF=$" --replace_string="&/etc/hosta
|
||||||
# isnt used ... instead the service is "pure systemd" ...
|
# isnt used ... instead the service is "pure systemd" ...
|
||||||
echo "DAEMON_CONF=/etc/hostapd/hostapd.conf" > /etc/default/hostapd
|
echo "DAEMON_CONF=/etc/hostapd/hostapd.conf" > /etc/default/hostapd
|
||||||
|
|
||||||
# Fix sources
|
# Apply configuration
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url}" --target_file="$final_path/config.php"
|
ynh_add_config --template="config.php.tpl" --destination="$final_path/config.php"
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -279,7 +263,6 @@ systemctl unmask hostapd # On some system e.g. RPi, for some reason hostapd is m
|
||||||
ynh_script_progression --message="Storing the config file checksum..."
|
ynh_script_progression --message="Storing the config file checksum..."
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$final_path/config.php"
|
|
||||||
ynh_store_file_checksum --file="/etc/init.d/hostapd"
|
ynh_store_file_checksum --file="/etc/init.d/hostapd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -99,15 +99,6 @@ do
|
||||||
ynh_secure_remove --file="$FILE"
|
ynh_secure_remove --file="$FILE"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove packages
|
|
||||||
if [[ $firmware_nonfree -eq 0 ]]; then
|
|
||||||
# Remove free firmwares
|
|
||||||
if ! dpkg -l firmware-atheros &> /dev/null; then
|
|
||||||
ynh_secure_remove --file="/lib/firmware/htc_7010.fw"
|
|
||||||
ynh_secure_remove --file="/lib/firmware/htc_9271.fw"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -58,17 +58,10 @@ ynh_script_progression --message="Restoring the app main directory..."
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
if [[ $firmware_nonfree -eq 1 ]]; then
|
if [[ $firmware_nonfree -eq 1 ]]; then
|
||||||
# check if non-free is set on sources.list
|
check_armbian_nonfree_conflict
|
||||||
if ! grep -q non-free /etc/apt/sources.list ; then
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
|
||||||
sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
|
|
||||||
fi
|
|
||||||
|
|
||||||
packages=$nonfree_packages
|
|
||||||
else
|
else
|
||||||
packages=$free_packages
|
pkg_dependencies="$pkg_dependencies $free_firmware_packages"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/lib/firmware/htc_7010.fw"
|
|
||||||
ynh_restore_file --origin_path="/lib/firmware/htc_9271.fw"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/sudoers.d/${app}_ynh"
|
ynh_restore_file --origin_path="/etc/sudoers.d/${app}_ynh"
|
||||||
|
@ -121,7 +114,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies "$pkg_dependencies" "$packages"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
|
@ -143,6 +136,7 @@ yunohost service add $service_name --description "Creates a Wi-Fi access point"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
hot_reload_usb_wifi_cards
|
||||||
wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }')
|
wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
if [[ -z $wifi_device ]]; then
|
if [[ -z $wifi_device ]]; then
|
||||||
|
|
|
@ -80,13 +80,6 @@ ynh_clean_setup () {
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK THE PATH
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -122,12 +115,13 @@ ynh_add_nginx_config
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
if [[ $firmware_nonfree -eq 1 ]]; then
|
if [[ $firmware_nonfree -eq 1 ]]; then
|
||||||
packages=$nonfree_packages
|
check_armbian_nonfree_conflict
|
||||||
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
|
||||||
else
|
else
|
||||||
packages=$free_packages
|
pkg_dependencies="$pkg_dependencies $free_firmware_packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies" "$packages"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -168,10 +162,7 @@ ynh_replace_string --match_string="__PHPVERSION__" --replace_string="${phpversio
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modifying a config file..."
|
ynh_script_progression --message="Modifying a config file..."
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/config.php"
|
ynh_add_config --template="config.php.tpl" --destination="$final_path/config.php"
|
||||||
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url}" --target_file="$final_path/config.php"
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum --file="$final_path/config.php"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -205,6 +196,7 @@ yunohost service add $service_name --description "Creates a Wi-Fi access point"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
hot_reload_usb_wifi_cards
|
||||||
wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
if [[ -z $wifi_device ]]; then
|
if [[ -z $wifi_device ]]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue