From df369ac45be87f2969f5fbeab05dcf1b85de9cfc Mon Sep 17 00:00:00 2001 From: Michi-80337 <83032848+michi-80337@users.noreply.github.com> Date: Wed, 16 Jun 2021 00:17:48 +0200 Subject: [PATCH 1/4] Fixes issue #289 (1/2) Add option for to specify external IP address --- bbb-install.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bbb-install.sh b/bbb-install.sh index 52cbfa3..793df06 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -54,6 +54,7 @@ OPTIONS (install BigBlueButton): -v Install given version of BigBlueButton (e.g. 'bionic-23') (required) -s Configure server with + -i Configure server with specified IP -e Email for Let's Encrypt certbot -x Use Let's Encrypt certbot with manual dns challenges @@ -112,7 +113,7 @@ main() { need_x64 - while builtin getopts "hs:r:c:v:e:p:m:lxgtadwX" opt "${@}"; do + while builtin getopts "hs:i:r:c:v:e:p:m:lxgtadwX" opt "${@}"; do case $opt in h) @@ -126,6 +127,13 @@ main() { err "You must specify a valid hostname (not the hostname given in the docs)." fi ;; + i) + if [ -n "$IP" ]; then + err "Only one external IP address allowed." + fi + IP=$OPTARG + check_ip $IP + ;; r) PACKAGE_REPOSITORY=$OPTARG ;; @@ -576,6 +584,21 @@ check_host() { fi } +check_ip() { + local ip=$1 + + ip=${ip//[1-9]/1} + ip=${ip//1[01][01]/3} + ip=${ip//1[01]/2} + ip=${ip//0/1} + ip=${ip//[123]/0} + if [ "${ip}" != "0.0.0.0" ]; then + err "IP address $1 doesn't follow x.x.x.x syntax." + elif (( ( ${1//./ > 255 ) || ( } > 255 ) )) ; then + err "IP address $1 is out of range (0-255 for each component)." + fi +} + check_coturn() { if ! echo $1 | grep -q ':'; then err "Option for coturn must be :"; fi From 4f5d9350fbc9c524b451afc74c62d1d76a1ffd45 Mon Sep 17 00:00:00 2001 From: Michi-80337 <83032848+michi-80337@users.noreply.github.com> Date: Wed, 16 Jun 2021 01:11:20 +0200 Subject: [PATCH 2/4] Fixes issue #289 (2/2) Switch from deprecated net-tools (ifconfig, route, ...) to iproute2 package (ip address, ip route, ...), and try to make automatic external IP detection a little bit more reliable. --- bbb-install.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bbb-install.sh b/bbb-install.sh index 793df06..9ace7d2 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -460,12 +460,18 @@ get_IP() { if [ ! -z "$IP" ]; then return 0; fi # Determine local IP - need_pkg net-tools - if LANG=c ifconfig | grep -q 'venet0:0'; then - IP=$(ifconfig | grep -v '127.0.0.1' | grep -E "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | tail -1 | cut -d: -f2 | awk '{ print $1}') - else - IP=$(ifconfig $(route | grep ^default | head -1 | sed "s/.* //") | awk '/inet /{ print $2}' | cut -d: -f2) - fi + need_pkg iproute2 + local route=$(ip route show | grep -w -e "^default" | tail -1) + case $route in + *\ src\ *) + IP=$(sed -e "s/.* src //" -e "s/\([^ ]*\)\(.*\)/\1/" <<<$route) + ;; + *\ dev\ *) + local device=$(sed -e "s/.* dev //" -e "s/\([^ ]*\)\(.*\)/\1/" <<<$route) + IP=$(ip address show $device | grep -w -e "inet" | \ + grep " $device$" | sed -e "s/\(.*inet \)\([^ /]*\)\(.*\)/\2/") + ;; + esac # Determine external IP if [ -r /sys/devices/virtual/dmi/id/product_uuid ] && [ `head -c 3 /sys/devices/virtual/dmi/id/product_uuid` == "EC2" ]; then From da2c5bd8eae781fb438ce95053f57b05f350381a Mon Sep 17 00:00:00 2001 From: Michi-80337 <83032848+michi-80337@users.noreply.github.com> Date: Wed, 16 Jun 2021 00:17:48 +0200 Subject: [PATCH 3/4] Fixes issue #289 (1/2) Add option for to specify external IP address Merged commit 0165b6dd284ef750b5a4d806a71fd6ab0e3cb575 into this branch --- bbb-install.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bbb-install.sh b/bbb-install.sh index 4299b14..650ba67 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -54,6 +54,7 @@ OPTIONS (install BigBlueButton): -v Install given version of BigBlueButton (e.g. 'bionic-23') (required) -s Configure server with + -i Configure server with specified IP -e Email for Let's Encrypt certbot -x Use Let's Encrypt certbot with manual dns challenges @@ -112,7 +113,7 @@ main() { need_x64 - while builtin getopts "hs:r:c:v:e:p:m:lxgadw" opt "${@}"; do + while builtin getopts "hs:i:r:c:v:e:p:m:lxgadw" opt "${@}"; do case $opt in h) @@ -126,6 +127,13 @@ main() { err "You must specify a valid hostname (not the hostname given in the docs)." fi ;; + i) + if [ -n "$IP" ]; then + err "Only one external IP address allowed." + fi + IP=$OPTARG + check_ip $IP + ;; r) PACKAGE_REPOSITORY=$OPTARG ;; @@ -571,6 +579,21 @@ check_host() { fi } +check_ip() { + local ip=$1 + + ip=${ip//[1-9]/1} + ip=${ip//1[01][01]/3} + ip=${ip//1[01]/2} + ip=${ip//0/1} + ip=${ip//[123]/0} + if [ "${ip}" != "0.0.0.0" ]; then + err "IP address $1 doesn't follow x.x.x.x syntax." + elif (( ( ${1//./ > 255 ) || ( } > 255 ) )) ; then + err "IP address $1 is out of range (0-255 for each component)." + fi +} + check_coturn() { if ! echo "$1" | grep -q ':'; then err "Option for coturn must be :"; fi From 308e7740db05b0c4e3b648bafd1e973711f703b1 Mon Sep 17 00:00:00 2001 From: Michi-80337 <83032848+michi-80337@users.noreply.github.com> Date: Wed, 16 Jun 2021 01:11:20 +0200 Subject: [PATCH 4/4] Fixes issue #289 (2/2) Switch from deprecated net-tools (ifconfig, route, ...) to iproute2 package (ip address, ip route, ...), and try to make automatic external IP detection a little bit more reliable. Resolve conflict with master branch. --- bbb-install.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bbb-install.sh b/bbb-install.sh index 650ba67..faf0cb2 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -455,12 +455,18 @@ get_IP() { if [ -n "$IP" ]; then return 0; fi # Determine local IP - need_pkg net-tools - if LANG=c ifconfig | grep -q 'venet0:0'; then - IP=$(ifconfig | grep -v '127.0.0.1' | grep -E "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | tail -1 | cut -d: -f2 | awk '{ print $1}') - else - IP=$(ifconfig "$(route | grep ^default | head -1 | sed "s/.* //")" | awk '/inet /{ print $2}' | cut -d: -f2) - fi + need_pkg iproute2 + local route=$(ip route show | grep -w -e "^default" | tail -1) + case $route in + *\ src\ *) + IP=$(sed -e "s/.* src //" -e "s/\([^ ]*\)\(.*\)/\1/" <<<$route) + ;; + *\ dev\ *) + local device=$(sed -e "s/.* dev //" -e "s/\([^ ]*\)\(.*\)/\1/" <<<$route) + IP=$(ip address show $device | grep -w -e "inet" | \ + grep " $device$" | sed -e "s/\(.*inet \)\([^ /]*\)\(.*\)/\2/") + ;; + esac # Determine external IP if [ -r /sys/devices/virtual/dmi/id/product_uuid ] && [ "$(head -c 3 /sys/devices/virtual/dmi/id/product_uuid)" == "EC2" ]; then