Skip to content

Commit

Permalink
Merge pull request #4 from tebexio/1.0.0-beta
Browse files Browse the repository at this point in the history
1.0.0 beta
  • Loading branch information
WildBamaBoy authored May 3, 2024
2 parents 2b19022 + ff9cfb8 commit 27fa2e7
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

.DS_STORE
.idea/
deploy/linux/
deploy/windows/
deploy/osx/

# User-specific files
*.rsuser
Expand Down
21 changes: 19 additions & 2 deletions Tebex-RCON/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,30 @@
// Handle bad plugin type selection
if (pluginType == null)
{
Console.WriteLine($"No plugin for game '{startupGame}', please provide your desired plugin as a launch argument: ");
Console.WriteLine($"No plugin for game '{startupGame}', please provide your desired plugin as a launch argument or enter it below: ");
Console.WriteLine("Available plugins: ");
foreach (var plugName in pluginsAvailable)
{
Console.WriteLine($" - '{plugName}'");
}
return;

Console.WriteLine("Enter which plugin you want to run: ");

while (true) // Ask the user which plugin to run until they quit.
{
Console.Write("Tebex> ");
var desiredPlugin = Console.ReadLine();
if (desiredPlugin != null && pluginsAvailable.Contains(desiredPlugin))
{
startupGame = desiredPlugin;
break;
}

if (desiredPlugin != null && desiredPlugin.Equals("exit"))
{
return;
}
}
}

// Check command line flags
Expand Down
23 changes: 15 additions & 8 deletions Tebex-RCON/RCON/TebexRconAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Reflection;
using System;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Tebex.API;
using Tebex.RCON.Protocol;
Expand All @@ -10,7 +15,7 @@ namespace Tebex.Adapters
/** Provides logic that implements some RCON protocol */
public class TebexRconAdapter : BaseTebexAdapter
{
public const string Version = "1.0.0-alpha.5";
public const string Version = "1.0.0";
private const string ConfigFilePath = "./tebex-config.json";

private Type? _pluginType;
Expand Down Expand Up @@ -44,15 +49,17 @@ private TebexConfig ReadConfig()
public override void Init()
{
// Setup log
var currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (currentPath.Contains(":")) // linux service path separator
var currentPath = AppContext.BaseDirectory;
char pathSeparator = Path.PathSeparator;
if (pathSeparator == ':')
{
currentPath = currentPath.Replace(":", "/");
pathSeparator = '/';
}

var logName = $"TebexRcon-{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.log";
_logger = new StreamWriter(logName, true);
LogInfo($"Log file is being saved to '{currentPath}{Path.PathSeparator}{logName}'");
var logPath = currentPath + pathSeparator + logName;
_logger = new StreamWriter(logPath, true);
LogInfo($"Log file is being saved to '{currentPath}{pathSeparator}{logName}'");

LogInfo($"Tebex RCON Adapter Client {Version} | https://tebex.io/");

Expand Down
4 changes: 2 additions & 2 deletions Tebex-RCON/Tebex-RCON.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Tebex_RCON</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<PublishSingleFile>false</PublishSingleFile>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<PublishSingleFile>true</PublishSingleFile>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Tebex-RCON/Tebex/BaseTebexAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public void ProcessCommandQueue(bool ignoreWaitCheck = false)

LogInfo($"Executing offline command: `{parsedCommand}`");
ExecuteOfflineCommand(command, commandName, args.ToArray());
ExecutedCommands.Add(command);
}
}, (error) =>
{
Expand Down
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

rm -rf ./Tebex-RCON/bin
rm -rf ./Tebex-RCON/obj
rm -rf ./deploy/windows
rm -rf ./deploy/linux

dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=false .
dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=false .
dotnet publish -c Release -r osx-x64 --self-contained true -p:PublishSingleFile=false .

mkdir -p ./deploy/windows
mkdir -p ./deploy/linux
mkdir -p ./deploy/osx

cp ./Tebex-RCON/bin/Release/net7.0/win-x64/publish/* ./deploy/windows/
cp ./Tebex-RCON/bin/Release/net7.0/linux-x64/publish/* ./deploy/linux/
cp ./Tebex-RCON/bin/Release/net7.0/osx-x64/publish/* ./deploy/osx/
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions deploy/linux/pack.sh → deploy/linux-digitalocean/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Sync the Linux release to a remote server, to build a snapshot image of a basic RCON adapter

SNAPSHOT_SYSTEM="root@addr"
VERSION="1.0.0-alpha.5"
VERSION="1.0.0"

# Sync distribution files to the server used for snapshots
rsync -rv ../../Tebex-RCON/bin/Release/net7.0/linux-x64 $SNAPSHOT_SYSTEM:/root/Tebex-RCONAdapter/
rsync -v ./Tebex-RCONAdapter.service $SNAPSHOT_SYSTEM:/etc/systemd/Tebex-RCONAdapter.service
rsync -rv ../linux/ $SNAPSHOT_SYSTEM:/root/Tebex-RCONAdapter/linux-x64/
rsync -v ./Tebex-RCONAdapter.service $SNAPSHOT_SYSTEM:/etc/systemd/system/Tebex-RCONAdapter.service
rsync -v ./etc/motd $SNAPSHOT_SYSTEM:/etc/motd
rsync -rv ./root/* $SNAPSHOT_SYSTEM:/root/
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions deploy/linux-digitalocean/root/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

systemctl stop Tebex-RCONAdapter
sleep 1
systemctl status Tebex-RCONAdapter

echo "Stopped RCON Adapter."
5 changes: 0 additions & 5 deletions deploy/linux/root/stop.sh

This file was deleted.

0 comments on commit 27fa2e7

Please sign in to comment.