Skip to content

Instantly share code, notes, and snippets.

@Drac346
Last active December 29, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drac346/17e98ff1b4db664782f8ae54284eee47 to your computer and use it in GitHub Desktop.
Save Drac346/17e98ff1b4db664782f8ae54284eee47 to your computer and use it in GitHub Desktop.
Automating basic startup and shutdown functions for my 3x3 servers
Function Atlas-MainMenu {
#######
# Script Variables
#Atlas Executable in ""
$MainExe = "c:\games\atlas\ShooterGame\Binaries\Win64\ShooterGameServer.exe"
#Make sure you have the following settings configured in the ServerGrid.json: MaxPlayers, ReservedPlayerSlots, Ports, SeamlessIP
#Make sure you have the following configured in each servers GameUserSettings.ini: serverPVE=<0 for PVP, 1 for PVE>
#Add to the bottom of GameUserSettings.ini if it's not there so you don't need to call it in every startup file (Max of 150 players, reserved must be a smaller positive number)
#[/Script/Engine.GameSession]
#MaxPlayers=###
#ReservedPlayerSlots=##
#If using RCON, make sure you have the following confirued in each servers GameUserSettings.ini: ServerAdminPassword=<password>, RCONPort=<port>,RCONEnabled=true
$Atlas00Arg = "Ocean?ServerX=0?ServerY=0?AltSaveDirectoryName=A1 -log -server -NoBattlEye"
$Atlas01Arg = "Ocean?ServerX=0?ServerY=1?AltSaveDirectoryName=A2 -log -server -NoBattlEye"
$Atlas02Arg = "Ocean?ServerX=0?ServerY=2?AltSaveDirectoryName=A3 -log -server -NoBattlEye"
$Atlas10Arg = "Ocean?ServerX=1?ServerY=0?AltSaveDirectoryName=B1 -log -server -NoBattlEye"
$Atlas11Arg = "Ocean?ServerX=1?ServerY=1?AltSaveDirectoryName=B2 -log -server -NoBattlEye"
$Atlas12Arg = "Ocean?ServerX=1?ServerY=2?AltSaveDirectoryName=B3 -log -server -NoBattlEye"
$Atlas20Arg = "Ocean?ServerX=2?ServerY=0?AltSaveDirectoryName=C1 -log -server -NoBattlEye"
$Atlas21Arg = "Ocean?ServerX=2?ServerY=1?AltSaveDirectoryName=C2 -log -server -NoBattlEye"
$Atlas22Arg = "Ocean?ServerX=2?ServerY=2?AltSaveDirectoryName=C3 -log -server -NoBattlEye"
#CrossArkChat Executable in "" (if you are using it, ignore otherwise)
$CRCPath = "C:\Program Files\CrossArkChat\CrossArkChat.exe"
#Number of seconds to let the server start before starting the next server
$SleepTime = "30"
#End Variables
######
do
{
Function Show-Menu{
Param(
[String[]]$Title = "Atlas Server Main Menu"
)
cls
Write-Host $Title
Write-Host ""
Write-Host "1: Start All Servers"
Write-Host "2: Start one server"
Write-Host "3: Get Atlas Processes IDs; (optional) Stop one or more Processes"
Write-Host "4: Steam Update"
Write-Host "5: Start CrossAtlasChat Bot"
Write-Host "6: Start Redis"
Write-Host "q: Quit"
}
Function Start-AtlasServer {
Param(
[Parameter(Mandatory=$True,Position=0,HelpMessage="This is just a name to help you keep track of what you are doing")]
[ValidateNotNullOrEmpty()]
[alias("in","name")]
[String[]]
$InstanceName,
[Parameter(Mandatory=$True,Position=1,HelpMessage="path to the shootergameserver.exe; in quotes if there are spaces")]
[ValidateNotNullOrEmpty()]
[String[]]
[alias("path","ep")]
$ExePath,
[Parameter(Mandatory=$True,Position=2,HelpMessage="this is everything after the .exe in quote")]
[ValidateNotNullOrEmpty()]
[alias("arg","args","a")]
[String[]]
$Arguments,
[Parameter(Mandatory=$false,Position=3,HelpMessage="Idle, Normal, High, or RealTime")]
[ValidateNotNullOrEmpty()]
[alias("p","pri")]
[ValidateSet("Idle","Normal","High","RealTime")]
[String[]]
$Priority,
[Parameter(Mandatory=$false,Position=4,HelpMessage="Speicify a CPU number if you want CPU affinity, 0 = no affinity")]
[ValidateNotNullOrEmpty()]
[alias("affin","cpu","processor")]
[Int]
$Affinity
)
cls
Write-Host "Starting up Server: " $InstanceName
Start-Process -FilePath $ExePath -ArgumentList $Arguments -PassThru
Write-Host "sleeping for " $SleepTime " Seconds"
Start-Sleep -Seconds $SleepTime
}
Show-Menu
$Selection = Read-Host "Please make a selection"
If ($Selection -eq "1") {
Write-Host "Starting all server instances"
Start-AtlasServer A1-DracsHeart $MainExe $Atlas00Arg
Start-AtlasServer A2-TheHoppining $MainExe $Atlas01Arg
Start-AtlasServer A3-BellsHell $MainExe $Atlas02Arg
Start-AtlasServer B1-NightsFury $MainExe $Atlas10Arg
Start-AtlasServer B2-KellsMaw $MainExe $Atlas11Arg
Start-AtlasServer B3-CrooniesSurprise $MainExe $Atlas12Arg
Start-AtlasServer C1-PrincessPebbles $MainExe $Atlas20Arg
Start-AtlasServer C2-DAINNSS $MainExe $Atlas21Arg
Start-AtlasServer C3-KnowBotty $MainExe $Atlas22Arg
Write-Host "Startup Complete"
}
elseif ($Selection -eq "2"){
Write-Host ""
Write-Host "Which Instance do you want to startup?"
Write-Host "1: A1-DracsHeart"
Write-Host "2: A2-TheHoppining"
Write-Host "3: A3-BellsHell"
Write-Host "4: B1-NightsFury"
Write-Host "5: B2-KellsMaw"
Write-Host "6: B3-CrooniesSurprise"
Write-Host "7: C1-PrincessPebbles"
Write-Host "8: C2-DAINNSS"
Write-Host "9: C3-KnowBotty"
Write-Host "any other key to go back to main menu"
$StartupSelection = Read-Host
If ($StartupSelection -eq "1"){Start-AtlasServer A1-DracsHeart $MainExe $Atlas00Arg}
Elseif ($StartupSelection -eq "2") {Start-AtlasServer A2-TheHoppining $MainExe $Atlas01Arg}
Elseif ($StartupSelection -eq "3") {Start-AtlasServer A3-BellsHell $MainExe $Atlas02Arg}
Elseif ($StartupSelection -eq "4") {Start-AtlasServer B1-NightsFury $MainExe $Atlas10Arg}
Elseif ($StartupSelection -eq "5") {Start-AtlasServer B2-KellsMaw $MainExe $Atlas11Arg}
Elseif ($StartupSelection -eq "6") {Start-AtlasServer B3-CrooniesSurprise $MainExe $Atlas12Arg}
Elseif ($StartupSelection -eq "7") {Start-AtlasServer C1-PrincessPebbles $MainExe $Atlas20Arg}
Elseif ($StartupSelection -eq "8") {Start-AtlasServer C2-DAINNSS $MainExe $Atlas21Arg}
Elseif ($StartupSelection -eq "9") {Start-AtlasServer C3-KnowBotty $MainExe $Atlas22Arg}
}
elseif ($Selection -eq "3"){
Get-Process -Name ShooterGameServer | select ID, MainWindowTitle
Write-Host ""
Write-Host "1: To Stop One Instance"
Write-Host "2: To stop All Instance"
Write-Host "Enter any other key to return to the main menu"
$PIDTask = Read-Host
If ($PIDTask = "1") {
Write-Host "Please enter the Process ID you wish to stop"
$STOPPID = Read-Host
Write-Host "Stopping Process " $STOPPID
Stop-Process $STOPPID
}
elseif ($PIDTask = "2") {
Write-Host "ARE YOU SURE (Y to Continue)?"
$Confirm = Read-Host
If ($Confirm.ToUpper() -eq "Y"){(Get-Process -Name ShooterGameServer).Id | Stop-Process}
}
}
elseif ($Selection -eq "4"){
Write-Host "Starting Steam Update"
$SteamExe = "c:\Program Files\steamcmd\steamcmd.exe"
$SteamArgs = "+login anonymous +force_install_dir c:\games\atlas +app_update 1006030 validate +quit"
Start-Process -FilePath $SteamExe -ArgumentList $SteamArgs -PassThru
Write-Host "Steam Update Complete"
}
elseif ($Selection -eq "5"){
Write-Host "Checking for Existing Process: CrossArkChat"
$CACRunning = (Get-Process -Name CrossArkChat -ErrorAction SilentlyContinue) -eq $null
If ($CACRunning -eq $false) {
Write-Host "Process not found, starting:"
Start-Process -FilePath $CRCPath -PassThru
Start-Sleep -s 2
Get-Process -Name CrossArkChat
} else {
Write-Host "Process was found running; please terminate and try again"
Get-Process -Name CrossArkChat
}
}
elseif ($Selection -eq "6"){
Write-Host "Checking for Existing Service: redis"
Write-Host "I'm assuming you installed the EXE already and we are just checking the status of the service"
$CACRunning = (Get-Service Redis).Status
If ($CACRunning -ne "Running") {
Write-Host "Process is not running"
Start-Service -Name Redis
Start-Sleep -s 2
Write-Host "Status: " (Get-Service Redis).Status
} else {
Write-Host "Service was found running"
Write-Host "Status: " (Get-Service Redis).Status
}
}
}
until ($Selection -eq 'q')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment