[macOS] Add apache and nginx (#2522)

* add apache and nginx

* swap config and service status

* add new line

* remove notes
This commit is contained in:
Aleksandr Chebotov
2021-01-26 17:14:31 +03:00
committed by GitHub
parent ed5d4dc5c5
commit 5537d89215
7 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
#!/bin/bash -e -o pipefail
brew install httpd
sudo sed -Ei '' 's/Listen .*/Listen 80/' $(brew --prefix)/etc/httpd/httpd.conf
invoke_tests "WebServers" "Apache"

View File

@@ -0,0 +1,6 @@
#!/bin/bash -e -o pipefail
brew install nginx
sudo sed -Ei '' 's/listen.*/listen 80;/' $(brew --prefix)/etc/nginx/nginx.conf
invoke_tests "WebServers" "Nginx"

View File

@@ -14,6 +14,7 @@ Import-Module "$PSScriptRoot/SoftwareReport.Java.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Xamarin.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Toolcache.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Browsers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.WebServers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../helpers/SoftwareReport.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
@@ -219,6 +220,11 @@ $markdown += New-MDHeader "PowerShell Modules" -Level 4
$markdown += Get-PowerShellModules | New-MDTable
$markdown += New-MDNewLine
# Web Servers
if ($os.IsHigherThanMojave) {
$markdown += Build-WebServersSection
}
# Xamarin section
$markdown += New-MDHeader "Xamarin" -Level 3
$markdown += New-MDHeader "Visual Studio for Mac" -Level 4

View File

@@ -0,0 +1,41 @@
function Get-ApacheVersion {
$name = "httpd"
$port = 80
$version = brew list $name --versions | Take-Part -Part 1
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
$configFile = "$(brew --prefix)/etc/httpd/httpd.conf"
return [PsCustomObject]@{
"Name" = $name
"Version" = $version
"ConfigFile" = $configFile
"ServiceStatus" = $serviceStatus
"ListenPort" = $port
}
}
function Get-NginxVersion {
$name = "nginx"
$port = 80
$version = brew list $name --versions | Take-Part -Part 1
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
$configFile = "$(brew --prefix)/etc/nginx/nginx.conf"
return [PsCustomObject]@{
"Name" = $name
"Version" = $version
"ConfigFile" = $configFile
"ServiceStatus" = $serviceStatus
"ListenPort" = $port
}
}
function Build-WebServersSection {
$output = ""
$output += New-MDHeader "Web Servers" -Level 3
$output += @(
(Get-ApacheVersion),
(Get-NginxVersion)
) | Sort-Object Name | New-MDTable
$output += New-MDNewLine
return $output
}

View File

@@ -174,6 +174,8 @@
"./provision/core/xamarin-android-ndk.sh",
"./provision/core/vsmac.sh",
"./provision/core/nvm.sh",
"./provision/core/apache.sh",
"./provision/core/nginx.sh",
"./provision/core/postgresql.sh",
"./provision/core/mongodb.sh",
"./provision/core/audiodevice.sh",

View File

@@ -173,6 +173,8 @@
"./provision/core/xamarin.sh",
"./provision/core/vsmac.sh",
"./provision/core/nvm.sh",
"./provision/core/apache.sh",
"./provision/core/nginx.sh",
"./provision/core/postgresql.sh",
"./provision/core/mongodb.sh",
"./provision/core/vcpkg.sh",

View File

@@ -0,0 +1,19 @@
Describe "Apache" {
It "Apache CLI" {
"httpd -v" | Should -ReturnZeroExitCode
}
It "Apache Service" {
brew services list | Out-String | Should -Match "httpd\s+stopped"
}
}
Describe "Nginx" {
It "Nginx CLI" {
"nginx -v" | Should -ReturnZeroExitCode
}
It "Nginx Service" {
brew services list | Out-String | Should -Match "nginx\s+stopped"
}
}