mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Code review / add quotes around suspicious vars that may be empty
This commit is contained in:
parent
fbf6e7acc1
commit
c39e31a92c
5 changed files with 17 additions and 17 deletions
|
@ -25,7 +25,7 @@ function used_iw_devices()
|
||||||
local other_hotspot_apps=$(grep -F -x -v $app <<< ${hotspot_apps})
|
local other_hotspot_apps=$(grep -F -x -v $app <<< ${hotspot_apps})
|
||||||
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
|
||||||
|
|
|
@ -27,7 +27,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
get__no_antenna() {
|
get__no_antenna() {
|
||||||
if [[ $(unused_iw_devices) == "" ]]
|
if [[ "$(unused_iw_devices)" == "" ]]
|
||||||
then
|
then
|
||||||
echo "value: true"
|
echo "value: true"
|
||||||
else
|
else
|
||||||
|
@ -39,7 +39,7 @@ get__status() {
|
||||||
local service_enabled=$(ynh_app_setting_get $app service_enabled)
|
local service_enabled=$(ynh_app_setting_get $app service_enabled)
|
||||||
if systemctl is-active hostapd@$app -q
|
if systemctl is-active hostapd@$app -q
|
||||||
then
|
then
|
||||||
if [[ $service_enabled -eq 1 ]]
|
if [[ "$service_enabled" -eq 1 ]]
|
||||||
then
|
then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
style: success
|
style: success
|
||||||
|
@ -54,7 +54,7 @@ ask:
|
||||||
en: Your Hotspot is running, but it shouldn't !
|
en: Your Hotspot is running, but it shouldn't !
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
elif [[ $service_enabled -eq 1 ]]
|
elif [[ "$service_enabled" -eq 1 ]]
|
||||||
then
|
then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
style: danger
|
style: danger
|
||||||
|
@ -77,7 +77,7 @@ EOF
|
||||||
|
|
||||||
get__wifi_device() {
|
get__wifi_device() {
|
||||||
local unused_wifi_devices=$(unused_iw_devices)
|
local unused_wifi_devices=$(unused_iw_devices)
|
||||||
if [[ -z ${unused_wifi_devices} ]]
|
if [[ -z "${unused_wifi_devices}" ]]
|
||||||
then
|
then
|
||||||
echo "choices: []"
|
echo "choices: []"
|
||||||
else
|
else
|
||||||
|
@ -99,11 +99,11 @@ get__dns() {
|
||||||
ip4_nat_prefix=$(ynh_app_setting_get --app=$app --key=ip4_nat_prefix)
|
ip4_nat_prefix=$(ynh_app_setting_get --app=$app --key=ip4_nat_prefix)
|
||||||
ip4_dns=$(ynh_app_setting_get --app=$app --key=ip4_dns)
|
ip4_dns=$(ynh_app_setting_get --app=$app --key=ip4_dns)
|
||||||
|
|
||||||
if [[ -n ${ip6_net} ]] && [[ -z ${ip6_dns} ]]; then
|
if [[ -n "${ip6_net}" ]] && [[ -z "${ip6_dns}" ]]; then
|
||||||
ip6_dns="${ip6_net}1"
|
ip6_dns="${ip6_net}1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${ip4_nat_prefix} ]] && [[ -z ${ip4_dns} ]]; then
|
if [[ -n "${ip4_nat_prefix}" ]] && [[ -z "${ip4_dns}" ]]; then
|
||||||
ip4_dns="${ip4_nat_prefix}.1"
|
ip4_dns="${ip4_nat_prefix}.1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ set__dns() {
|
||||||
ip6_dns="${ip6_dns%%,}"
|
ip6_dns="${ip6_dns%%,}"
|
||||||
ip4_dns="${ip4_dns%%,}"
|
ip4_dns="${ip4_dns%%,}"
|
||||||
|
|
||||||
if [[ -n ${ip6_net} ]] && [[ -z ${ip6_dns} ]]; then
|
if [[ -n "${ip6_net}" ]] && [[ -z "${ip6_dns}" ]]; then
|
||||||
ip6_dns="${ip6_net}1"
|
ip6_dns="${ip6_net}1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${ip4_nat_prefix} ]] && [[ -z ${ip4_dns} ]]; then
|
if [[ -n "${ip4_nat_prefix}" ]] && [[ -z "${ip4_dns}" ]]; then
|
||||||
ip4_dns="${ip4_nat_prefix}.1"
|
ip4_dns="${ip4_nat_prefix}.1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ systemctl disable hostapd --quiet 2>&1
|
||||||
systemctl stop hostapd 2>&1
|
systemctl stop hostapd 2>&1
|
||||||
systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd is masked after install ...
|
systemctl unmask hostapd 2>&1 # On some system e.g. RPi, for some reason hostapd is masked after install ...
|
||||||
|
|
||||||
if [[ -n ${wifi_device} ]]; then
|
if [[ -n "${wifi_device}" ]]; then
|
||||||
configure_hostapd
|
configure_hostapd
|
||||||
configure_dhcp
|
configure_dhcp
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -107,7 +107,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
|
hot_reload_usb_wifi_cards
|
||||||
if [[ -z $wifi_device ]] || ! grep -q -F $wifi_device <(unused_iw_devices); then
|
if [[ -z "$wifi_device" ]] || ! grep -q -F "$wifi_device" <(unused_iw_devices); then
|
||||||
wifi_device=$(unused_iw_devices | head -n 1)
|
wifi_device=$(unused_iw_devices | head -n 1)
|
||||||
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
|
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -84,7 +84,7 @@ if [ -z $service_name ]; then
|
||||||
ynh_app_setting_set --app=$app --key=service_name --value=$service_name
|
ynh_app_setting_set --app=$app --key=service_name --value=$service_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${multissid} ]] && [[ ${multissid} -gt 1 ]]; then
|
if [[ -n "${multissid}" ]] && [[ "${multissid}" -gt 1 ]]; then
|
||||||
wifi_ssid=$(cut -d'|' -f 1 <<< ${wifi_ssid})
|
wifi_ssid=$(cut -d'|' -f 1 <<< ${wifi_ssid})
|
||||||
wifi_secure=$(cut -d'|' -f 1 <<< ${wifi_secure})
|
wifi_secure=$(cut -d'|' -f 1 <<< ${wifi_secure})
|
||||||
wifi_passphrase=$(cut -d'|' -f 1 <<< ${wifi_passphrase})
|
wifi_passphrase=$(cut -d'|' -f 1 <<< ${wifi_passphrase})
|
||||||
|
@ -129,7 +129,7 @@ else
|
||||||
ip4_dns=$(ynh_app_setting_get --app=$app --key=ip4_dns)
|
ip4_dns=$(ynh_app_setting_get --app=$app --key=ip4_dns)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${multissid} ]]; then
|
if [[ -n "${multissid}" ]]; then
|
||||||
ynh_app_setting_delete --app=$app --key=multissid
|
ynh_app_setting_delete --app=$app --key=multissid
|
||||||
|
|
||||||
ynh_secure_remove --file="/etc/hostapd/hostapd.conf"
|
ynh_secure_remove --file="/etc/hostapd/hostapd.conf"
|
||||||
|
@ -138,7 +138,7 @@ if [[ -n ${multissid} ]]; then
|
||||||
ynh_secure_remove --file="/etc/dnsmasq.dhcpd/"
|
ynh_secure_remove --file="/etc/dnsmasq.dhcpd/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${advanced} ]]; then
|
if [[ -z "${advanced}" ]]; then
|
||||||
ynh_app_setting_set --app=$app --key=advanced --value=0
|
ynh_app_setting_set --app=$app --key=advanced --value=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_script_progression --message="Copying configuration..."
|
ynh_script_progression --message="Copying configuration..."
|
||||||
|
|
||||||
hot_reload_usb_wifi_cards
|
hot_reload_usb_wifi_cards
|
||||||
if [[ -z $wifi_device ]] || ! grep -q -F $wifi_device <(unused_iw_devices); then
|
if [[ -z "$wifi_device" ]] || ! grep -q -F "$wifi_device" <(unused_iw_devices); then
|
||||||
wifi_device=$(unused_iw_devices | head -n 1)
|
wifi_device="$(unused_iw_devices | head -n 1)"
|
||||||
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
|
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ install -b -o root -g root -m 0644 ../conf/hostapd.conf.tpl /etc/hostapd/$app/ho
|
||||||
install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl
|
install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv6.conf.tpl /etc/dnsmasq.$app/dhcpdv6.conf.tpl
|
||||||
install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl
|
install -b -o root -g root -m 0644 ../conf/dnsmasq_dhcpdv4.conf.tpl /etc/dnsmasq.$app/dhcpdv4.conf.tpl
|
||||||
|
|
||||||
if [[ -n ${wifi_device} ]]; then
|
if [[ -n "${wifi_device}" ]]; then
|
||||||
configure_hostapd
|
configure_hostapd
|
||||||
configure_dhcp
|
configure_dhcp
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue