Skip to content

Instantly share code, notes, and snippets.

@mxyq
Last active August 2, 2022 03:37
Show Gist options
  • Save mxyq/b58f957a6f45303c6f916cf4b26dec51 to your computer and use it in GitHub Desktop.
Save mxyq/b58f957a6f45303c6f916cf4b26dec51 to your computer and use it in GitHub Desktop.
[Read from type] #Bash
read -n1 -r -p "Press any key to continue..."
echo
echo "Which protocol should OpenVPN use?"
echo " 1) UDP (recommended)"
echo " 2) TCP"
read -p "Protocol [1]: " protocol
until [[ -z "$protocol" || "$protocol" =~ ^[12]$ ]]; do
echo "$protocol: invalid selection."
read -p "Protocol [1]: " protocol
done
case "$protocol" in
1|"")
protocol=udp
;;
2)
protocol=tcp
;;
esac
echo
echo "What port should OpenVPN listen to?"
read -p "Port [1194]: " port
until [[ -z "$port" || "$port" =~ ^[0-9]+$ && "$port" -le 65535 ]]; do
echo "$port: invalid port."
read -p "Port [1194]: " port
done
[[ -z "$port" ]] && port="1194"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment