Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hwdsl2 committed Sep 12, 2023
1 parent a9ae409 commit 44b8cba
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ enter_server_address() {
read -rp "Enter the DNS name of this VPN server: " server_addr
done
ip="$server_addr"
echo
echo "Note: Make sure this DNS name resolves to the IPv4 address"
echo " of this server. If you add or update the DNS record"
echo " at a later time, reboot this server to take effect."
else
detect_ip
check_nat_ip
Expand Down Expand Up @@ -261,27 +265,9 @@ show_config() {
}

detect_ipv6() {
# If system has a single IPv6, it is selected automatically
if [[ $(ip -6 addr | grep -c 'inet6 [23]') -eq 1 ]]; then
ip6=$(ip -6 addr | grep 'inet6 [23]' | cut -d '/' -f 1 | grep -oE '([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}')
fi
# If system has multiple IPv6, ask the user to select one
if [[ $(ip -6 addr | grep -c 'inet6 [23]') -gt 1 ]]; then
if [ "$auto" = 0 ]; then
echo
echo "Which IPv6 address should be used?"
num_of_ip6=$(ip -6 addr | grep -c 'inet6 [23]')
ip -6 addr | grep 'inet6 [23]' | cut -d '/' -f 1 | grep -oE '([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}' | nl -s ') '
read -rp "IPv6 address [1]: " ip6_num
until [[ -z "$ip6_num" || "$ip6_num" =~ ^[0-9]+$ && "$ip6_num" -le "$num_of_ip6" ]]; do
echo "$ip6_num: invalid selection."
read -rp "IPv6 address [1]: " ip6_num
done
[[ -z "$ip6_num" ]] && ip6_num=1
else
ip6_num=1
fi
ip6=$(ip -6 addr | grep 'inet6 [23]' | cut -d '/' -f 1 | grep -oE '([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}' | sed -n "$ip6_num"p)
ip6=""
if [[ $(ip -6 addr | grep -c 'inet6 [23]') -ne 0 ]]; then
ip6=$(ip -6 addr | grep 'inet6 [23]' | cut -d '/' -f 1 | grep -oE '([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}' | sed -n 1p)
fi
}

Expand Down

0 comments on commit 44b8cba

Please sign in to comment.