From f29cc02bef4dcd5d5132d59c1287cbe5a531278f Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 7 Apr 2021 13:57:35 +0300 Subject: [PATCH] [Ubuntu] Remove apt sources for Postgresql, Mongodb, Heroku (#3091) --- .../scripts/SoftwareReport/SoftwareReport.Databases.psm1 | 6 ++++-- images/linux/scripts/helpers/SoftwareReport.Helpers.psm1 | 7 +++++++ images/linux/scripts/installers/heroku.sh | 2 +- images/linux/scripts/installers/mongodb.sh | 8 +++++++- images/linux/scripts/installers/postgresql.sh | 8 +++++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 index 450bcfeb2..e80c1b2d9 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -1,11 +1,13 @@ function Get-PostgreSqlVersion { $postgreSQLVersion = psql --version | Take-OutputPart -Part 2 - return "Postgre SQL $postgreSQLVersion" + $aptSourceRepo = Get-AptSourceRepository -PackageName "postgresql" + return "Postgre SQL $postgreSQLVersion (apt source repository: $aptSourceRepo)" } function Get-MongoDbVersion { $mongoDBVersion = mongod --version | Select-Object -First 1 | Take-OutputPart -Part 2 -Delimiter "v" - return "MongoDB $mongoDBVersion" + $aptSourceRepo = Get-AptSourceRepository -PackageName "mongodb" + return "MongoDB $mongoDBVersion (apt source repository: $aptSourceRepo)" } function Get-SqliteVersion { diff --git a/images/linux/scripts/helpers/SoftwareReport.Helpers.psm1 b/images/linux/scripts/helpers/SoftwareReport.Helpers.psm1 index a3ef19d1c..dfecd423b 100644 --- a/images/linux/scripts/helpers/SoftwareReport.Helpers.psm1 +++ b/images/linux/scripts/helpers/SoftwareReport.Helpers.psm1 @@ -103,3 +103,10 @@ function Get-CachedToolInstances return $toolInstances } +function Get-AptSourceRepository { + param([String] $PackageName) + + $sourceUrl = Get-Content "$PSScriptRoot/../helpers/apt-sources.txt" | Select-String -Pattern $PackageName | Take-OutputPart -Part 1 + return $sourceUrl +} + diff --git a/images/linux/scripts/installers/heroku.sh b/images/linux/scripts/installers/heroku.sh index 2c8862092..fa1e2d4be 100644 --- a/images/linux/scripts/installers/heroku.sh +++ b/images/linux/scripts/installers/heroku.sh @@ -5,6 +5,6 @@ ################################################################################ # Install Heroku CLI -curl https://cli-assets.heroku.com/install-ubuntu.sh | sh +curl https://cli-assets.heroku.com/install.sh | sh invoke_tests "Tools" "Heroku" \ No newline at end of file diff --git a/images/linux/scripts/installers/mongodb.sh b/images/linux/scripts/installers/mongodb.sh index ad1403668..ea0b4f426 100644 --- a/images/linux/scripts/installers/mongodb.sh +++ b/images/linux/scripts/installers/mongodb.sh @@ -7,11 +7,17 @@ # Source the helpers source $HELPER_SCRIPTS/os.sh +REPO_URL="https://repo.mongodb.org/apt/ubuntu" + # Install Mongo DB wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - version=$(getOSVersionLabel) -echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $version/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list +echo "deb [ arch=amd64,arm64 ] $REPO_URL $version/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list sudo apt-get update sudo apt-get install -y mongodb-org +rm /etc/apt/sources.list.d/mongodb-org-4.4.list + +echo "mongodb $REPO_URL" >> $HELPER_SCRIPTS/apt-sources.txt + invoke_tests "Databases" "MongoDB" diff --git a/images/linux/scripts/installers/postgresql.sh b/images/linux/scripts/installers/postgresql.sh index 4424adbf8..85b7dec0d 100644 --- a/images/linux/scripts/installers/postgresql.sh +++ b/images/linux/scripts/installers/postgresql.sh @@ -4,9 +4,11 @@ ## Desc: Installs Postgresql ################################################################################ +REPO_URL="https://apt.postgresql.org/pub/repos/apt/" + #Preparing repo for PostgreSQL 12. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -echo "deb https://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +echo "deb $REPO_URL `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list echo "Install PostgreSQL" apt update @@ -19,4 +21,8 @@ apt-get install libpq-dev systemctl is-active --quiet postgresql.service && systemctl stop postgresql.service systemctl disable postgresql.service +rm /etc/apt/sources.list.d/pgdg.list + +echo "postgresql $REPO_URL" >> $HELPER_SCRIPTS/apt-sources.txt + invoke_tests "Databases" "PostgreSQL"