mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Fix indent in _common.sh
This commit is contained in:
parent
ddc23c17b5
commit
f55f117625
1 changed files with 41 additions and 49 deletions
|
@ -14,31 +14,31 @@ free_firmware_packages="firmware-ath9k-htc"
|
||||||
|
|
||||||
function other_hotspot_apps()
|
function other_hotspot_apps()
|
||||||
{
|
{
|
||||||
local app_shortname="${app%%__*}"
|
local app_shortname="${app%%__*}"
|
||||||
local hotspot_apps=$(yunohost app list --output-as json | jq -r .apps[].id | grep -F $app_shortname)
|
local hotspot_apps=$(yunohost app list --output-as json | jq -r .apps[].id | grep -F $app_shortname)
|
||||||
# Remove this app from hotspot apps list
|
# Remove this app from hotspot apps list
|
||||||
grep -F -x -v $app <<< ${hotspot_apps}
|
grep -F -x -v $app <<< ${hotspot_apps}
|
||||||
}
|
}
|
||||||
|
|
||||||
function iw_devices()
|
function iw_devices()
|
||||||
{
|
{
|
||||||
/sbin/iw dev | grep Interface | grep -v 'mon\.' | grep -v hotspot | awk '{ print $NF }'
|
/sbin/iw dev | grep Interface | grep -v 'mon\.' | grep -v hotspot | awk '{ print $NF }'
|
||||||
}
|
}
|
||||||
|
|
||||||
function used_iw_devices()
|
function used_iw_devices()
|
||||||
{
|
{
|
||||||
for hotspot_app in $(other_hotspot_apps); do
|
for hotspot_app in $(other_hotspot_apps); do
|
||||||
hotspot_wifi_device=$(ynh_app_setting_get --app=$hotspot_app --key=wifi_device)
|
hotspot_wifi_device=$(ynh_app_setting_get --app=$hotspot_app --key=wifi_device)
|
||||||
if [[ -n "${hotspot_wifi_device}" ]]; then
|
if [[ -n "${hotspot_wifi_device}" ]]; then
|
||||||
echo "${hotspot_wifi_device}"
|
echo "${hotspot_wifi_device}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function unused_iw_devices()
|
function unused_iw_devices()
|
||||||
{
|
{
|
||||||
# Only prints devices that are not in the list of used devices
|
# Only prints devices that are not in the list of used devices
|
||||||
iw_devices | grep -F -v -f <(used_iw_devices)
|
iw_devices | grep -F -v -f <(used_iw_devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_armbian_nonfree_conflict()
|
function check_armbian_nonfree_conflict()
|
||||||
|
@ -47,10 +47,10 @@ function check_armbian_nonfree_conflict()
|
||||||
# If we're on armbian, force $firmware_nonfree
|
# If we're on armbian, force $firmware_nonfree
|
||||||
# because armbian-firmware conflicts with firmware-misc-nonfree package
|
# because armbian-firmware conflicts with firmware-misc-nonfree package
|
||||||
if dpkg --list | grep -q armbian-firmware; then
|
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 "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 "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
|
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//')
|
nonfree_firmware_packages=$(echo $nonfree_firmware_packages | sed 's/ firmware-ralink//')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,50 +58,42 @@ function check_armbian_nonfree_conflict()
|
||||||
|
|
||||||
function hot_reload_usb_wifi_cards()
|
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"
|
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
|
modprobe --quiet --remove $modulesList || true
|
||||||
possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq)
|
possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq)
|
||||||
for usbPath in $possibleUsbDevicesNeedingReload; do
|
for usbPath in $possibleUsbDevicesNeedingReload; do
|
||||||
if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then
|
if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then
|
||||||
echo "Try to reload driver for usb $usbPath" >&2
|
echo "Try to reload driver for usb $usbPath" >&2
|
||||||
echo 0 > /sys/bus/usb/devices/$usbPath/authorized
|
echo 0 > /sys/bus/usb/devices/$usbPath/authorized
|
||||||
echo 1 > /sys/bus/usb/devices/$usbPath/authorized
|
echo 1 > /sys/bus/usb/devices/$usbPath/authorized
|
||||||
# Wait for driver reloading
|
# Wait for driver reloading
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_hostapd()
|
function configure_hostapd()
|
||||||
{
|
{
|
||||||
if [[ "${wifi_secure}" -eq 1 ]]; then
|
if [[ "${wifi_secure}" -eq 1 ]]; then
|
||||||
sec_comment=""
|
sec_comment=""
|
||||||
else
|
else
|
||||||
sec_comment="#"
|
sec_comment="#"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf"
|
ynh_add_config --template="/etc/hostapd/$app/hostapd.conf.tpl" --destination="/etc/hostapd/$app/hostapd.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_dnsmasq()
|
function configure_dnsmasq()
|
||||||
{
|
{
|
||||||
ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf"
|
ynh_add_config --template="/etc/dnsmasq.$app/dnsmasq.conf.tpl" --destination="/etc/dnsmasq.d/$app.conf"
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_dhcp()
|
function configure_dhcp()
|
||||||
{
|
{
|
||||||
ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf"
|
ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv4.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv4.conf"
|
||||||
|
|
||||||
if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then
|
if [[ -n "${ip6_net}" ]] && [[ "${ip6_net}" != "none" ]]; then
|
||||||
ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv6.conf"
|
ynh_add_config --template="/etc/dnsmasq.$app/dhcpdv6.conf.tpl" --destination="/etc/dnsmasq.$app/dhcpdv6.conf"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue