From 5feb70b5414d7bfba4325acea944d2193b15b24f Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Fri, 12 Feb 2021 17:22:42 -0500 Subject: [PATCH 1/6] quiet some "tee"s by piping their output to /dev/null (like the other "tee"s) --- bbb-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bbb-install.sh b/bbb-install.sh index 85f36d3..48e9eed 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -289,7 +289,7 @@ main() { if ! apt-key list MongoDB | grep -q 4.2; then wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - fi - echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list + echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list > /dev/null rm -f /etc/apt/sources.list.d/mongodb-org-4.0.list touch /root/.rnd @@ -755,7 +755,7 @@ install_greenlight(){ # need_pkg bbb-webhooks if [ ! -f /etc/bigbluebutton/nginx/greenlight.nginx ]; then - docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /etc/bigbluebutton/nginx/greenlight.nginx + docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /etc/bigbluebutton/nginx/greenlight.nginx >/dev/null cat > /etc/bigbluebutton/nginx/greenlight-redirect.nginx << HERE location = / { return 307 /b; From 5608f31ec457d8664da8b5dcdb6408f8774ac44e Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Fri, 12 Feb 2021 17:23:20 -0500 Subject: [PATCH 2/6] use systemctl is-active to see if nginx is running; seems to be a better way to decide if we want to stop it --- bbb-install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bbb-install.sh b/bbb-install.sh index 48e9eed..fb6017f 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -484,8 +484,9 @@ get_IP() { # Check if the external IP reaches the internal IP if [ -n "$external_ip" ] && [ "$IP" != "$external_ip" ]; then - if which nginx; then + if systemctl -q is-active nginx; then systemctl stop nginx + NGINX_WAS_RUNING=true fi need_pkg netcat-openbsd @@ -510,7 +511,7 @@ get_IP() { kill $nc_PID > /dev/null 2>&1; - if which nginx; then + if [ ! -z $NGINX_WAS_RUNING ]; then systemctl start nginx fi fi From bb15fc10a9bd448e46ff40ee12e526b7918bd568 Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Fri, 12 Feb 2021 17:24:08 -0500 Subject: [PATCH 3/6] check for package installation using dpkg-query's status field instead of grep'ing for the package name in "dpkg -l" A problem with the grep'ing approach was that if a package was purged, it will still appear on "dpkg -l" and seem like it was installed. --- bbb-install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bbb-install.sh b/bbb-install.sh index fb6017f..1ceda0d 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -519,6 +519,10 @@ get_IP() { if [ -z "$IP" ]; then err "Unable to determine local IP address."; fi } +is_pkg_installed() { + [[ $(dpkg-query -W -f '${db:status-status}' $1 2>/dev/null) == "installed" ]] +} + need_pkg() { check_root while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 1; done @@ -602,7 +606,9 @@ check_coturn() { } check_apache2() { - if dpkg -l | grep -q apache2-bin; then err "You must uninstall the Apache2 server first"; fi + if is_pkg_installed apache2-bin; then + err "You must uninstall the Apache2 server first" + fi } # If running under LXC, then modify the FreeSWITCH systemctl service so it does not use realtime scheduler @@ -723,7 +729,7 @@ install_greenlight(){ install_docker # Purge older docker compose - if dpkg -l | grep -q docker-compose; then + if is_pkg_installed docker-compose; then apt-get purge -y docker-compose fi @@ -801,7 +807,7 @@ install_docker() { curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - fi - if ! dpkg -l | grep -q docker-ce; then + if ! is_pkg_installed docker-ce; then add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ From 6c7f34fc329c867f143c65d55baee4dd95e04cd4 Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Fri, 12 Feb 2021 17:26:33 -0500 Subject: [PATCH 4/6] silence warning messages from apt-key --- bbb-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bbb-install.sh b/bbb-install.sh index 1ceda0d..ceb1568 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -110,6 +110,9 @@ main() { LETS_ENCRYPT_OPTIONS="--webroot --non-interactive" SOURCES_FETCHED=false + # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? + export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true + need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadw" opt "${@}"; do From 2b5fc81a2d72ce58956eb9bf5901daf5772a9751 Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Tue, 10 Jan 2023 21:59:37 -0500 Subject: [PATCH 5/6] duplicate last four commits to bbb-install.sh into bbb-install-2.5.sh and bbb-install-2.6.sh --- bbb-install-2.5.sh | 22 +++++++++++++++------- bbb-install-2.6.sh | 22 +++++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/bbb-install-2.5.sh b/bbb-install-2.5.sh index ccc19bf..c02c177 100755 --- a/bbb-install-2.5.sh +++ b/bbb-install-2.5.sh @@ -117,6 +117,9 @@ main() { CR_TMPFILE=$(mktemp /tmp/carriage-return.XXXXXX) echo "\n" > $CR_TMPFILE + # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? + export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true + need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadwji" opt "${@}"; do @@ -275,7 +278,7 @@ main() { if ! apt-key list MongoDB | grep -q 4.4; then wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - fi - echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list + echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null rm -f /etc/apt/sources.list.d/mongodb-org-4.2.list touch /root/.rnd @@ -447,8 +450,9 @@ get_IP() { # Check if the external IP reaches the internal IP if [ -n "$external_ip" ] && [ "$IP" != "$external_ip" ]; then - if which nginx; then + if systemctl -q is-active nginx; then systemctl stop nginx + NGINX_WAS_RUNING=true fi need_pkg netcat-openbsd @@ -473,7 +477,7 @@ get_IP() { kill $nc_PID > /dev/null 2>&1; - if which nginx; then + if [ ! -z $NGINX_WAS_RUNING ]; then systemctl start nginx fi fi @@ -481,6 +485,10 @@ get_IP() { if [ -z "$IP" ]; then err "Unable to determine local IP address."; fi } +is_pkg_installed() { + [[ $(dpkg-query -W -f '${db:status-status}' $1 2>/dev/null) == "installed" ]] +} + need_pkg() { check_root while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do echo "Sleeping for 1 second because of dpkg lock"; sleep 1; done @@ -554,7 +562,7 @@ check_coturn() { } check_apache2() { - if dpkg -l | grep -q apache2-bin; then + if is_pkg_installed apache2-bin; then echo "You must uninstall the Apache2 server first" if [ "$SKIP_APACHE_INSTALLED_CHECK" != true ]; then exit 1 @@ -675,7 +683,7 @@ install_greenlight(){ docker pull bigbluebutton/greenlight:v2 # Ensure the current version of greenlight is pulled # Purge older docker compose - if dpkg -l | grep -q docker-compose; then + if is_pkg_installed docker-compose; then apt-get purge -y docker-compose fi @@ -708,7 +716,7 @@ install_greenlight(){ # need_pkg bbb-webhooks if [ ! -f /usr/share/bigbluebutton/nginx/greenlight.nginx ]; then - docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx + docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx >/dev/null cat > /usr/share/bigbluebutton/nginx/greenlight-redirect.nginx << HERE location = / { return 307 /b; @@ -753,7 +761,7 @@ install_docker() { curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - fi - if ! dpkg -l | grep -q docker-ce; then + if ! is_pkg_installed docker-ce; then add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ diff --git a/bbb-install-2.6.sh b/bbb-install-2.6.sh index 077bf07..0811fa4 100755 --- a/bbb-install-2.6.sh +++ b/bbb-install-2.6.sh @@ -111,6 +111,9 @@ main() { CR_TMPFILE=$(mktemp /tmp/carriage-return.XXXXXX) echo "\n" > $CR_TMPFILE + # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? + export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true + need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadwji" opt "${@}"; do @@ -270,7 +273,7 @@ main() { if ! apt-key list MongoDB | grep -q 4.4; then wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - fi - echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list + echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list > /dev/null rm -f /etc/apt/sources.list.d/mongodb-org-4.2.list touch /root/.rnd @@ -436,8 +439,9 @@ get_IP() { # Check if the external IP reaches the internal IP if [ -n "$external_ip" ] && [ "$IP" != "$external_ip" ]; then - if which nginx; then + if systemctl -q is-active nginx; then systemctl stop nginx + NGINX_WAS_RUNING=true fi need_pkg netcat-openbsd @@ -462,7 +466,7 @@ get_IP() { kill $nc_PID > /dev/null 2>&1; - if which nginx; then + if [ ! -z $NGINX_WAS_RUNING ]; then systemctl start nginx fi fi @@ -470,6 +474,10 @@ get_IP() { if [ -z "$IP" ]; then err "Unable to determine local IP address."; fi } +is_pkg_installed() { + [[ $(dpkg-query -W -f '${db:status-status}' $1 2>/dev/null) == "installed" ]] +} + need_pkg() { check_root while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do echo "Sleeping for 1 second because of dpkg lock"; sleep 1; done @@ -543,7 +551,7 @@ check_coturn() { } check_apache2() { - if dpkg -l | grep -q apache2-bin; then + if is_pkg_installed apache2-bin; then echo "You must uninstall the Apache2 server first" if [ "$SKIP_APACHE_INSTALLED_CHECK" != true ]; then exit 1; @@ -664,7 +672,7 @@ install_greenlight(){ docker pull bigbluebutton/greenlight:v2 # Ensure the current version of greenlight is pulled # Purge older docker compose - if dpkg -l | grep -q docker-compose; then + if is_pkg_installed docker-compose; then apt-get purge -y docker-compose fi @@ -697,7 +705,7 @@ install_greenlight(){ # need_pkg bbb-webhooks if [ ! -f /usr/share/bigbluebutton/nginx/greenlight.nginx ]; then - docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx + docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx >/dev/null cat > /usr/share/bigbluebutton/nginx/greenlight-redirect.nginx << HERE location = / { return 307 /b/; @@ -742,7 +750,7 @@ install_docker() { curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - fi - if ! dpkg -l | grep -q docker-ce; then + if ! is_pkg_installed docker-ce; then echo "deb [ arch=amd64 ] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list From f76cd3a114766c9e46a91172af921a7a13829404 Mon Sep 17 00:00:00 2001 From: Brent Baccala Date: Tue, 17 Jan 2023 21:08:27 -0500 Subject: [PATCH 6/6] remove APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true, since we want to find a better way of doing this --- bbb-install-2.5.sh | 3 --- bbb-install-2.6.sh | 3 --- bbb-install.sh | 3 --- 3 files changed, 9 deletions(-) diff --git a/bbb-install-2.5.sh b/bbb-install-2.5.sh index c02c177..a869a55 100755 --- a/bbb-install-2.5.sh +++ b/bbb-install-2.5.sh @@ -117,9 +117,6 @@ main() { CR_TMPFILE=$(mktemp /tmp/carriage-return.XXXXXX) echo "\n" > $CR_TMPFILE - # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? - export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true - need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadwji" opt "${@}"; do diff --git a/bbb-install-2.6.sh b/bbb-install-2.6.sh index 0811fa4..3f635bc 100755 --- a/bbb-install-2.6.sh +++ b/bbb-install-2.6.sh @@ -111,9 +111,6 @@ main() { CR_TMPFILE=$(mktemp /tmp/carriage-return.XXXXXX) echo "\n" > $CR_TMPFILE - # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? - export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true - need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadwji" opt "${@}"; do diff --git a/bbb-install.sh b/bbb-install.sh index ceb1568..1ceda0d 100755 --- a/bbb-install.sh +++ b/bbb-install.sh @@ -110,9 +110,6 @@ main() { LETS_ENCRYPT_OPTIONS="--webroot --non-interactive" SOURCES_FETCHED=false - # If grep'ing for a key in "apt-key list" is dangerous, should we find a better way to do it? - export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true - need_x64 while builtin getopts "hs:r:c:v:e:p:m:lxgadw" opt "${@}"; do