mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
prefill dns settings from nat and ipv6 prefix
This commit is contained in:
parent
186ec93570
commit
40534c2ac4
2 changed files with 22 additions and 6 deletions
|
@ -93,13 +93,20 @@ EOF
|
|||
}
|
||||
|
||||
get__dns() {
|
||||
ip6_dns=$(ynh_app_setting_get $app ip6_dns | tr -d '[' | tr -d ']')
|
||||
ip6_dns=$(ynh_app_setting_get $app ip6_dns | tr -d '[]')
|
||||
ip4_dns=$(ynh_app_setting_get $app ip4_dns)
|
||||
|
||||
|
||||
if [[ -n ${ip6_net} ]] && [[ -z ${ip6_dns} ]]; then
|
||||
ip6_dns="${ip6_net}1"
|
||||
fi
|
||||
|
||||
if [[ -n ${ip4_nat_prefix} ]] && [[ -z ${ip4_dns} ]]; then
|
||||
ip4_dns="${ip4_nat_prefix}.1"
|
||||
fi
|
||||
|
||||
echo "value: ${ip4_dns},${ip6_dns}"
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
@ -154,6 +161,14 @@ set__dns() {
|
|||
ip6_dns="${ip6_dns%%,}"
|
||||
ip4_dns="${ip4_dns%%,}"
|
||||
|
||||
if [[ -n ${ip6_net} ]] && [[ -z ${ip6_dns} ]]; then
|
||||
ip6_dns="${ip6_net}1"
|
||||
fi
|
||||
|
||||
if [[ -n ${ip4_nat_prefix} ]] && [[ -z ${ip4_dns} ]]; then
|
||||
ip4_dns="${ip4_nat_prefix}.1"
|
||||
fi
|
||||
|
||||
ynh_app_setting_set $app ip6_dns "${ip6_dns}"
|
||||
ynh_app_setting_set $app ip4_dns "${ip4_dns}"
|
||||
}
|
||||
|
|
|
@ -117,14 +117,15 @@ ynh_system_user_create --username=$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring hotspot..."
|
||||
|
||||
ip6_net=""
|
||||
ip6_dns=""
|
||||
if [[ ! -v ip6_net ]]; then # if ip6_net not set
|
||||
ip6_net=""
|
||||
|
||||
if [[ -e /tmp/.ynh-vpnclient-started ]]; then
|
||||
vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1)
|
||||
|
||||
if [[ $vpnclient_ip6_net =~ :: ]]; then
|
||||
ip6_net=${vpnclient_ip6_net}
|
||||
ip6_dns="${ip6_net}1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -138,7 +139,7 @@ ynh_app_setting_set --app=$app --key=wifi_passphrase --value="${wifi_passphrase}
|
|||
ynh_app_setting_set --app=$app --key=wifi_device --value="${wifi_device}"
|
||||
ynh_app_setting_set --app=$app --key=wifi_channel --value=6
|
||||
ynh_app_setting_set --app=$app --key=ip6_firewall --value=1
|
||||
ynh_app_setting_set --app=$app --key=ip6_dns --value=""
|
||||
ynh_app_setting_set --app=$app --key=ip6_dns --value="${ip6_dns}"
|
||||
ynh_app_setting_set --app=$app --key=ip6_net --value="${ip6_net}"
|
||||
ynh_app_setting_set --app=$app --key=ip4_dns --value="10.0.242.1"
|
||||
ynh_app_setting_set --app=$app --key=ip4_nat_prefix --value=10.0.242
|
||||
|
|
Loading…
Reference in a new issue