mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Get rid of ip6_addr, compute it based on the ip6_net instead
This commit is contained in:
parent
fdce1dd305
commit
e2d7a00861
3 changed files with 12 additions and 26 deletions
|
@ -30,6 +30,12 @@ has_ip6delegatedprefix() {
|
|||
[[ -n "${ynh_ip6_net[${i}]}" ]] && [[ "${ynh_ip6_net[${i}]}" != "none" ]]
|
||||
}
|
||||
|
||||
ip6addrfromdelegatedprefix() {
|
||||
i=${1}
|
||||
|
||||
echo "${ynh_ip6_net[${i}]}${i}001"
|
||||
}
|
||||
|
||||
is_nat_set() {
|
||||
internet_device=${1}
|
||||
|
||||
|
@ -47,7 +53,7 @@ is_ip6addr_set() {
|
|||
i=${1}
|
||||
dev=$(devfromid "${i}")
|
||||
|
||||
ip address show dev "${dev}" 2> /dev/null | grep -q "${ynh_ip6_addr[${i}]}/64"
|
||||
ip address show dev "${dev}" 2> /dev/null | grep -q "$(ip6addrfromdelegatedprefix $i)/64"
|
||||
}
|
||||
|
||||
is_ip6firewall_set() {
|
||||
|
@ -114,8 +120,8 @@ set_ip6addr() {
|
|||
i=${1}
|
||||
dev=$(devfromid "${i}")
|
||||
|
||||
ip address delete "${ynh_ip6_addr[${i}]}/64" dev tun0 &> /dev/null
|
||||
ip address add "${ynh_ip6_addr[${i}]}/64" dev "${dev}"
|
||||
ip address delete "$(ip6addrfromdelegatedprefix $i)/64" dev tun0 &> /dev/null
|
||||
ip address add "$(ip6addrfromdelegatedprefix $i)/64" dev "${dev}"
|
||||
}
|
||||
|
||||
set_ip6firewall() {
|
||||
|
@ -213,7 +219,7 @@ unset_ip6addr() {
|
|||
i=${1}
|
||||
dev=$(devfromid "${i}")
|
||||
|
||||
ip address delete "${ynh_ip6_addr[${i}]}/64" dev "${dev}"
|
||||
ip address delete "$(ip6addrfromdelegatedprefix $i)/64" dev "${dev}"
|
||||
}
|
||||
|
||||
unset_ip6firewall() {
|
||||
|
@ -300,7 +306,6 @@ if [ "$1" != restart ]; then
|
|||
IFS='|' read -a ynh_wifi_ssid <<< "$(ynh_setting_get hotspot wifi_ssid)"
|
||||
IFS='|' read -a ynh_wifi_secure <<< "$(ynh_setting_get hotspot wifi_secure)"
|
||||
IFS='|' read -a ynh_wifi_passphrase <<< "$(ynh_setting_get hotspot wifi_passphrase)"
|
||||
IFS='|' read -a ynh_ip6_addr <<< "$(ynh_setting_get hotspot ip6_addr)"
|
||||
IFS='|' read -a ynh_ip6_firewall <<< "$(ynh_setting_get hotspot ip6_firewall)"
|
||||
IFS='|' read -a ynh_ip6_net <<< "$(ynh_setting_get hotspot ip6_net)"
|
||||
IFS='|' read -a ynh_dns <<< "$(ynh_setting_get hotspot dns)"
|
||||
|
@ -534,7 +539,7 @@ case "$1" in
|
|||
for i in $(seq 0 $((${ynh_multissid} - 1))); do
|
||||
if has_ip6delegatedprefix ${i}; then
|
||||
echo "[INFO] hotspot${i}: IPv6 delegated prefix found"
|
||||
echo "[INFO] hotspot${i}: IPv6 address computed from the delegated prefix: ${ynh_ip6_addr}"
|
||||
echo "[INFO] hotspot${i}: IPv6 address computed from the delegated prefix: $(ip6addrfromdelegatedprefix $i)"
|
||||
|
||||
if is_ip6addr_set ${i}; then
|
||||
echo "[OK] hotspot${i}: IPv6 address set"
|
||||
|
|
|
@ -119,15 +119,12 @@ ynh_script_progression --message="Configuring hotspot..."
|
|||
|
||||
if [[ ! -v ip6_net ]]; then # if ip6_net not set
|
||||
ip6_net=""
|
||||
ip6_addr=""
|
||||
|
||||
if [[ -e /tmp/.ynh-vpnclient-started ]]; then
|
||||
vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1)
|
||||
vpnclient_ip6_addr=$(ynh_app_setting_get vpnclient ip6_addr 2>&1)
|
||||
|
||||
if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then
|
||||
if [[ $vpnclient_ip6_net =~ :: ]]; then
|
||||
ip6_net=${vpnclient_ip6_net}
|
||||
ip6_addr=${vpnclient_ip6_addr}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -142,7 +139,6 @@ ynh_app_setting_set --app=$app --key=wifi_secure --value=1
|
|||
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_addr --value="${ip6_addr}"
|
||||
ynh_app_setting_set --app=$app --key=ip6_firewall --value=1
|
||||
ynh_app_setting_set --app=$app --key=ip6_net --value="${ip6_net}"
|
||||
ynh_app_setting_set --app=$app --key=dns --value="2001:913::8,2001:910:800::12,80.67.188.188,80.67.169.12"
|
||||
|
@ -199,14 +195,6 @@ ynh_script_progression --message="Configuring a systemd service..."
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service=$service_name
|
||||
|
||||
# Remove IPv6 address set if there is a VPN installed
|
||||
# ... but why ? ...
|
||||
if [[ $ip6_addr != "" ]]; then
|
||||
if ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"; then
|
||||
ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
|
|
@ -80,13 +80,6 @@ then
|
|||
ynh_app_setting_set --app=$app --key=ip6_net --value="$ip6_net"
|
||||
fi
|
||||
|
||||
ip6_addr=$(ynh_app_setting_get --app=$app --key=ip6_addr)
|
||||
if [ "$ip6_addr" == "none" ]
|
||||
then
|
||||
ip6_addr=""
|
||||
ynh_app_setting_set --app=$app --key=ip6_addr --value="$ip6_addr"
|
||||
fi
|
||||
|
||||
if [ -f /etc/nginx/conf.d/*.d/$app.conf ]; then
|
||||
ynh_secure_remove /etc/nginx/conf.d/*.d/$app.conf
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
|
Loading…
Reference in a new issue