add documentation how to install server on ubuntu 20.04 and add server version stuff
This commit is contained in:
84
MareSynchronosServer/Installation-Linux.md
Normal file
84
MareSynchronosServer/Installation-Linux.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# Installing Mare Server on Ubuntu 20.04 Server LTS
|
||||||
|
|
||||||
|
## Important
|
||||||
|
- **You _will_ need a valid Certificate for the server.**
|
||||||
|
- Set one up using LetsEncrypt or use the one provided by your hoster
|
||||||
|
- The server provided is only guaranteed to run under Ubuntu 20.04 Server LTS. For anything else, you are on your own. The server is provided as a standalone .NET application which does not require .NET Core to be installed.
|
||||||
|
|
||||||
|
## Copy files over
|
||||||
|
- Connect via SCP and copy over all files to some directory
|
||||||
|
- The directory will need to be writeable by the user
|
||||||
|
|
||||||
|
## Install MSSQL Server 2019 CU
|
||||||
|
- Import GPG keys
|
||||||
|
```sh
|
||||||
|
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
||||||
|
```
|
||||||
|
- Add repository
|
||||||
|
```sh
|
||||||
|
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"
|
||||||
|
```
|
||||||
|
- Install SQL Server 2019
|
||||||
|
```
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y mssql-server
|
||||||
|
```
|
||||||
|
- Run configuration
|
||||||
|
```
|
||||||
|
sudo /opt/mssql/bin/mssql-conf setup
|
||||||
|
```
|
||||||
|
- Install "3) Express"
|
||||||
|
- Set a password
|
||||||
|
- Verify server is running
|
||||||
|
```
|
||||||
|
systemctl status mssql-server --no-pager
|
||||||
|
```
|
||||||
|
- Optional: set up a separate user for Mare Synchronos
|
||||||
|
- I'll let you figure that out yourself
|
||||||
|
- The user will need database creation rights
|
||||||
|
|
||||||
|
## Configure Mare Server
|
||||||
|
- open provided appsettings.json
|
||||||
|
- edit `DefaultConnection` to `"Server=localhost;User=sa;Password=<sa password>;Database=mare;MultipleActiveResultSets=true"`
|
||||||
|
- if you created a separate user for mare on the SQL Server, specify the username and password here
|
||||||
|
- edit `CacheDirectory` and set it to a path where the file cache is supposed to be located. i.e. `/home/<user>/servercache`
|
||||||
|
- you will also need to create that folder
|
||||||
|
- optional: set Port under edit `Url` and change the `+:5000` to `+:<your port>`
|
||||||
|
|
||||||
|
- Set up `Certificate`
|
||||||
|
- Set `Path` to the certificate file path
|
||||||
|
- Set `Password` to the password of the certificate
|
||||||
|
- If the certificate file is split in private key and public, set `KeyPath` to the private key file
|
||||||
|
- Delete all unused keys from `Certificate`
|
||||||
|
|
||||||
|
## Set up Mare Synchonos Server as a Service
|
||||||
|
- create new file `/etc/systemd/system/MareSynchronosServer.service` with following contents
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Mare Synchronos Service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=<path to server files>
|
||||||
|
ExecStart=<path to server files>/MareSynchronosServer
|
||||||
|
SysLogIdentifier=MareSynchronosServer
|
||||||
|
User=<the user to run the service with>
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
- Reload SystemD daemon
|
||||||
|
```
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
```
|
||||||
|
- Enable the service with
|
||||||
|
```
|
||||||
|
sudo systemctl enable MareSynchronosServer
|
||||||
|
```
|
||||||
|
- Start the service with
|
||||||
|
```
|
||||||
|
sudo systemctl start MareSynchronosServer
|
||||||
|
```
|
||||||
|
- Log in ingame and add a custom server within the Mare Synchronos Plugin configuration under the address `wss://<your server ip>:<your server port>`
|
||||||
|
- That should be it and your server ready to go and running
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
public record LoggedInUserDto
|
public record ConnectionDto
|
||||||
{
|
{
|
||||||
|
public int ServerVersion { get; set; }
|
||||||
public bool IsAdmin { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
public bool IsModerator { get; set; }
|
public bool IsModerator { get; set; }
|
||||||
public string UID { get; set; }
|
public string UID { get; set; }
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "6.0.6",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.ConstrainedExecution;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MareSynchronos.API;
|
using MareSynchronos.API;
|
||||||
@@ -10,11 +11,12 @@ namespace MareSynchronosServer.Hubs
|
|||||||
{
|
{
|
||||||
public class ConnectionHub : BaseHub<ConnectionHub>
|
public class ConnectionHub : BaseHub<ConnectionHub>
|
||||||
{
|
{
|
||||||
|
private const int ServerVersion = 1;
|
||||||
public ConnectionHub(MareDbContext mareDbContext, ILogger<ConnectionHub> logger) : base(mareDbContext, logger)
|
public ConnectionHub(MareDbContext mareDbContext, ILogger<ConnectionHub> logger) : base(mareDbContext, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<LoggedInUserDto> Heartbeat()
|
public async Task<ConnectionDto> Heartbeat()
|
||||||
{
|
{
|
||||||
var userId = Context.User!.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;
|
var userId = Context.User!.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
@@ -23,15 +25,16 @@ namespace MareSynchronosServer.Hubs
|
|||||||
{
|
{
|
||||||
Logger.LogInformation("Connection from " + userId);
|
Logger.LogInformation("Connection from " + userId);
|
||||||
var user = (await DbContext.Users.SingleAsync(u => u.UID == userId));
|
var user = (await DbContext.Users.SingleAsync(u => u.UID == userId));
|
||||||
return new LoggedInUserDto
|
return new ConnectionDto
|
||||||
{
|
{
|
||||||
|
ServerVersion = ServerVersion,
|
||||||
UID = userId,
|
UID = userId,
|
||||||
IsModerator = user.IsModerator,
|
IsModerator = user.IsModerator,
|
||||||
IsAdmin = user.IsAdmin
|
IsAdmin = user.IsAdmin
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LoggedInUserDto();
|
return new ConnectionDto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using MareSynchronosServer.Data;
|
using MareSynchronosServer.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@@ -20,7 +19,10 @@ namespace MareSynchronosServer
|
|||||||
{
|
{
|
||||||
var services = scope.ServiceProvider;
|
var services = scope.ServiceProvider;
|
||||||
var context = services.GetRequiredService<MareDbContext>();
|
var context = services.GetRequiredService<MareDbContext>();
|
||||||
context.Database.EnsureCreated();
|
context.Database.Migrate();
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
// clean up residuals
|
||||||
var users = context.Users.Where(u => u.CharacterIdentification != null);
|
var users = context.Users.Where(u => u.CharacterIdentification != null);
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ namespace MareSynchronosServer
|
|||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.UseSystemd()
|
||||||
.UseConsoleLifetime()
|
.UseConsoleLifetime()
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user