Skip to content

Commit

Permalink
Merge pull request #9 from hjorslev/dev
Browse files Browse the repository at this point in the history
Fix #7 - Rework so Get-SteamServerInfo uses Server queries -- !deploy !ver:MAJOR
  • Loading branch information
hjorslev authored May 19, 2020
2 parents a56152d + 9df18e7 commit c9e64b1
Show file tree
Hide file tree
Showing 19 changed files with 370 additions and 1,036 deletions.
43 changes: 43 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# EditorConfig is awesome: https://EditorConfig.org
# .NET coding convention settings for EditorConfig
# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference
#
# This file comes from dotnet repositories:
# https://github.com/dotnet/runtime/blob/master/.editorconfig
# https://github.com/dotnet/roslyn/blob/master/.editorconfig

# Top-most EditorConfig file
root = true

[*]
charset = utf-8-bom
# indent_size intentionally not specified in this section
indent_style = space

# Source code
[*.{cs,ps1,psd1,psm1}]
indent_size = 4

# Shell scripts
[*.sh]
indent_size = 4

# Xml project files
[*.{csproj,resx,ps1xml}]
indent_size = 2

# Data serialization
[*.{json,yaml,yml}]
indent_size = 2

# Markdown
[*.md]
indent_size = 2

# Xml files
[*.{resx,ruleset,stylecop,xml,xsd,xsl}]
indent_size = 2

# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
Expand Down
26 changes: 14 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"editor.tabSize": 4,
"editor.autoIndent": "full",
"editor.insertSpaces": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.renderWhitespace": "boundary",
"editor.wordWrap": "off",
"editor.detectIndentation": true,
"files.trimTrailingWhitespace": true,
"powershell.codeFormatting.preset": "OTBS",
"powershell.scriptAnalysis.settingsPath": ".\\PSScriptAnalyzerSettings.psd1",
}
"editor.tabSize": 4,
"editor.autoIndent": "full",
"editor.insertSpaces": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.renderWhitespace": "boundary",
"editor.detectIndentation": true,
"files.trimTrailingWhitespace": true,
"powershell.codeFormatting.preset": "OTBS",
"powershell.scriptAnalysis.settingsPath": ".\\PSScriptAnalyzerSettings.psd1",
"cSpell.words": [
"cmdlet"
]
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/)
and this project adheres to [Semantic Versioning](https://semver.org/).

## [3.0.0] - 19/05-2020

### Fixed

- Place external help inside module folder instead of the project folder.

### Changed

- Update-SteamServer
- Change parameter ApplicationPath to Path. Set old parameter as an alias.
- Change parameter LogLocation to LogPath. Set old parameter as an alias.
- Get-SteamServerInfo
- The cmdlet now uses Steam server queries to fetch data about the server. Added
new parameters `-IPAddress`, `-Port` and `-Timeout`. Removed parameter `-ServerID`
since the cmdlet is no longer dependent on Rust Server Info.

## [2.0.3] - 05/01-2020

### Added
Expand Down
76 changes: 66 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

## Build Status

[![AppVeyor master](https://img.shields.io/appveyor/ci/hjorslev/SteamPS/master?label=MASTER&logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/hjorslev/steamps)
[![AppVeyor tests (master)](https://img.shields.io/appveyor/tests/hjorslev/SteamPS/master?label=MASTER&logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/hjorslev/steamps/build/tests)
[![AppVeyor dev](https://img.shields.io/appveyor/ci/hjorslev/SteamPS/DEV?label=DEV&logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/hjorslev/steamps)
[![AppVeyor tests (dev)](https://img.shields.io/appveyor/tests/hjorslev/SteamPS/dev?label=DEV&logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/hjorslev/steamps/build/tests)
[![PowerShell Version](https://img.shields.io/powershellgallery/v/SteamPS.svg?style=for-the-badge&logo=PowerShell)](https://www.powershellgallery.com/packages/SteamPS)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SteamPS?style=for-the-badge)](https://www.powershellgallery.com/packages/SteamPS)
[![AppVeyor master](https://img.shields.io/appveyor/ci/hjorslev/SteamPS/master?label=MASTER&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps)
[![AppVeyor tests (master)](https://img.shields.io/appveyor/tests/hjorslev/SteamPS/master?label=MASTER&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps/build/tests)
[![AppVeyor dev](https://img.shields.io/appveyor/ci/hjorslev/SteamPS/DEV?label=DEV&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps)
[![AppVeyor tests (dev)](https://img.shields.io/appveyor/tests/hjorslev/SteamPS/dev?label=DEV&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps/build/tests)
[![Codacy master grade](https://img.shields.io/codacy/grade/bf0bb30dfc904b2f885c4f0ccdf1ea78/master?label=MASTER&style=flat)](https://app.codacy.com/manual/hjorslev/SteamPS/dashboard?bid=13716491)
[![Codacy dev grade](https://img.shields.io/codacy/grade/bf0bb30dfc904b2f885c4f0ccdf1ea78/dev?label=DEV&style=flat)](https://app.codacy.com/manual/hjorslev/SteamPS/dashboard?bid=13716490)

## Introduction

[![PowerShell Version](https://img.shields.io/powershellgallery/v/SteamPS.svg?style=flat&logo=PowerShell)](https://www.powershellgallery.com/packages/SteamPS)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SteamPS?style=flat)](https://www.powershellgallery.com/packages/SteamPS)

This cmdlet utilizes SteamCMD and eases the installation and updating of servers.

Install or update a Steam application using SteamCMD.
Expand Down Expand Up @@ -40,7 +43,6 @@ Install-Module -Name SteamPS

When SteamPS is installed we will need to use the cmdlet `Install-SteamCMD` from
the module to install SteamCMD.

2. This is done by calling Install-SteamCMD from an elevated prompt:

```powershell
Expand All @@ -49,14 +51,68 @@ Install-SteamCMD

By using the parameter -InstallPath you can specify an install location of SteamCMD.

## Cmdlets

| Cmdlet | Description |
| ------------------- | --------------------------------------------------------------- |
| Find-SteamAppID | Find a Steam AppID by searching the name of the application. |
| Get-SteamServerInfo | Query a running steam based game server. |
| Install-SteamCMD | Install SteamCMD. |
| Update-SteamApp | Install or update a Steam application using SteamCMD. |
| Update-SteamServer | Update a Steam based game server through a particular workflow. |

## Examples

The cmdlets must be executed from an elevated prompt.

### Update single app / game server

Add a game / server by searching for its name. Because there are multiple hits
when searching for Arma 3, the user will be promoted to select the right application.

```powershell
# Add a game / server by searching for its name. Because there are multiple hits when searching for Arma 3, the user will be promoted to select the right application.
Update-SteamApp -GameName 'Arma 3' -Credential Toby -Path 'C:\Servers\Arma3'
```

Here we use anonymous login because the particular application
(ARK: SurvivalEvolved Dedicated Server) doesn't require authentication to install
the server.

```powershell
Update-SteamApp -AppID 376030 -Path 'C:\Servers\ARK-SurvivalEvolved'
```

### Server update flow

The cmdlet Update-SteamServer is, at least for my own use case, applied to automatically
keep a server up-to-date. It will check the if the server is empty before updating
it.

Game servers must be ran as a [Windows Service](https://www.howtogeek.com/50786/using-srvstart-to-run-any-application-as-a-windows-service/).
There are also commercial programs available such as [FireDaemon](https://firedaemon.com/firedaemon-pro/).

#### Introduction

# Here we use anonymous login because the particular application (ARK: Survival Evolved Dedicated Server) doesn't require login.
Update-SteamApp -AppID 376030 -Path 'C:\Servers\Arma3'
Per default, all servers are installed at `C:\DedicatedServers\$ServiceName`. This
can be altered using the `-ApplicationPath` parameter.

If you want to have your server automatically updated, then remember to consider
backup of the server as well as fallback.

#### Workflow

```powershell
Update-SteamServer -AppID 476400 -ServiceName 'GB-PG10' -IPAddress '185.15.73.207' -Port 27015
```

1. `Update-SteamServer` will fetch the server info to check if the server is empty.
If not, it will wait until the server is empty before updating.
2. It will stop the server by stopping the Windows Service named *GB-PG10*.
3. It will update the server.
4. When the server is updated it will check to see that the server is online. Default
is to check every minute for a maximum of 10 times before the server is declared
offline.
1. By specifying the parameter `-DiscordWebhookUri` you can have a notification
if the server fails to update.
2. If you specify the parameter `-AlwaysNotify` alongside `-DiscordWebhookUri`
you will always receive a message with a status of the server update.
6 changes: 4 additions & 2 deletions SteamPS.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Add-BuildTask Init {

# Synopsis: Pester Tests
Add-BuildTask Test {
Remove-Module -Name $env:BHProjectName -Force -ErrorAction SilentlyContinue
Import-Module $env:BHPSModuleManifest -Force -Global
# Invoke Pester to run all of the unit tests, then save the results into XML in order to populate the AppVeyor tests section
# If any of the tests fail, consider the pipeline failed
$PesterResults = Invoke-Pester -Path "$($env:BHProjectPath)\Tests" -OutputFormat NUnitXml -OutputFile "$($env:BHProjectPath)\Tests\TestsResults.xml" -PassThru
Expand Down Expand Up @@ -80,8 +82,8 @@ Add-BuildTask BuildDocs {
}

Import-Module $env:BHPSModuleManifest -Force -Global
New-MarkdownHelp -Module $($env:BHProjectName) -OutputFolder '.\docs\' -Force
New-ExternalHelp -Path '.\docs\' -OutputPath ".\en-US\" -Force
New-MarkdownHelp -Module $env:BHProjectName -OutputFolder "$($env:BHProjectPath)\docs" -Force
New-ExternalHelp -Path "$($env:BHProjectPath)\docs" -OutputPath "$($env:BHModulePath)\en-US\" -Force
Copy-Item -Path '.\README.md' -Destination 'docs\index.md'
Copy-Item -Path '.\CHANGELOG.md' -Destination 'docs\CHANGELOG.md'
} else {
Expand Down
Empty file removed SteamPS/Class/.gitkeep
Empty file.
40 changes: 40 additions & 0 deletions SteamPS/Private/Get-PacketString.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function Get-PacketString {
<#
.SYNOPSIS
Get a string in a byte stream.
.DESCRIPTION
Get a string in a byte stream.
.PARAMETER Stream
Accepts BinaryReader.
.EXAMPLE
Get-PacketString -Stream $Stream
Assumes that you already have a byte stream. See more detailed usage in
Get-SteamServerInfo.
.NOTES
Author: Jordan Borean and Chris Dent
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.IO.BinaryReader]$Stream
)

process {
# Find the end of the string, terminated with \0 and convert that byte range to a string.
$stringBytes = while ($true) {
$byte = $Stream.ReadByte()
if ($byte -eq 0) {
break
}
$byte
}

[System.Text.Encoding]::UTF8.GetString($stringBytes)
} # Process
} # Cmdlet
5 changes: 3 additions & 2 deletions SteamPS/Public/Find-SteamAppID.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function Find-SteamAppID {
<#
.SYNOPSIS
Find a Steam AppID by searching using the name of the application.
Find a Steam AppID by searching the name of the application.
.DESCRIPTION
Find a Steam AppID by searching using the name of the application.
Find a Steam AppID by searching the name of the application.
.PARAMETER ApplicationName
Enter the name of the application. If multiple hits the user will be presented
Expand Down Expand Up @@ -36,6 +36,7 @@
https://hjorslev.github.io/SteamPS/Find-SteamAppID.html
#>

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
[CmdletBinding()]
param (
[Parameter(Position = 0,
Expand Down
Loading

0 comments on commit c9e64b1

Please sign in to comment.