Files
runner-images/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1
T

77 lines
2.3 KiB
PowerShell
Raw Normal View History

function Get-PostgreSqlVersion {
2020-09-14 10:09:05 +03:00
$postgreSQLVersion = psql --version | Take-OutputPart -Part 2
$aptSourceRepo = Get-AptSourceRepository -PackageName "postgresql"
2021-08-19 12:54:18 +02:00
return "PostgreSQL $postgreSQLVersion (apt source repository: $aptSourceRepo)"
}
function Get-MongoDbVersion {
2020-09-14 10:09:05 +03:00
$mongoDBVersion = mongod --version | Select-Object -First 1 | Take-OutputPart -Part 2 -Delimiter "v"
$aptSourceRepo = Get-AptSourceRepository -PackageName "mongodb"
return "MongoDB $mongoDBVersion (apt source repository: $aptSourceRepo)"
}
function Get-SqliteVersion {
2020-09-14 10:09:05 +03:00
$sqliteVersion = sqlite3 --version | Take-OutputPart -Part 0
return "sqlite3 $sqliteVersion"
}
2020-09-14 11:31:41 +03:00
function Get-MySQLVersion {
2021-12-07 23:38:14 +03:00
$mySQLVersion = mysqld --version | Take-OutputPart -Part 2
if (Test-IsUbuntu18) {
$mySQLVersion = $mySQLVersion | Take-OutputPart -Part 0 -Delimiter "-"
}
2020-09-14 16:27:20 +03:00
return "MySQL $mySQLVersion"
2020-09-14 10:09:05 +03:00
}
2020-11-17 10:18:27 +03:00
function Get-SQLCmdVersion {
$sqlcmdVersion = sqlcmd -? | Select-String -Pattern "Version" | Take-OutputPart -Part 1
return "sqlcmd $sqlcmdVersion"
}
2021-07-12 00:59:56 -07:00
function Get-SqlPackageVersion {
$sqlPackageVersion = sqlpackage /version
return "SqlPackage $sqlPackageVersion"
}
function Build-PostgreSqlSection {
$output = ""
$output += New-MDHeader "PostgreSQL" -Level 4
$output += New-MDList -Style Unordered -Lines @(
(Get-PostgreSqlVersion ),
"PostgreSQL Server (user:postgres)"
)
$output += New-MDCode -Lines @(
"PostgreSQL service is disabled by default. Use the following command as a part of your job to start the service: 'sudo systemctl start postgresql.service'"
)
return $output
}
2020-09-14 10:09:05 +03:00
function Build-MySQLSection {
$output = ""
$output += New-MDHeader "MySQL" -Level 4
$output += New-MDList -Style Unordered -Lines @(
2020-09-14 11:31:41 +03:00
(Get-MySQLVersion ),
2020-11-17 10:18:27 +03:00
"MySQL Server (user:root password:root)"
2020-09-14 10:09:05 +03:00
)
$output += New-MDCode -Lines @(
"MySQL service is disabled by default. Use the following command as a part of your job to start the service: 'sudo systemctl start mysql.service'"
)
2020-11-17 10:18:27 +03:00
return $output
}
function Build-MSSQLToolsSection {
$output = ""
$output += New-MDHeader "MS SQL Server Client Tools" -Level 4
$output += New-MDList -Style Unordered -Lines @(
2021-07-12 00:59:56 -07:00
(Get-SQLCmdVersion),
(Get-SqlPackageVersion)
2020-11-17 10:18:27 +03:00
)
2020-09-14 10:09:05 +03:00
return $output
2021-08-19 12:54:18 +02:00
}