Got more stuff connected up and working
This commit is contained in:
parent
7cddfd2de6
commit
a1141cd2b8
7 changed files with 111 additions and 97 deletions
|
@ -6,7 +6,7 @@ COPY . .
|
|||
WORKDIR /
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
RUN apt-get install -y git wget curl unzip xz-utils zip libglu1-mesa clang cmake ninja-build pkg-config libgtk3-dev liblzma-dev libstdc++-12-dev
|
||||
RUN apt-get install -y git wget curl unzip xz-utils zip libglu1-mesa clang cmake ninja-build pkg-config libgtk3-dev liblzma-dev libstdc++-12-dev rsync
|
||||
|
||||
RUN curl -O flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.22.1-stable.tar.xz
|
||||
RUN tar -xvf flutter.tar.xz
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:libac_flutter/packets/packets.dart';
|
||||
import 'package:libac_flutter/utils/IOTools.dart';
|
||||
import 'package:servermanager/game.dart';
|
||||
import 'package:servermanager/packets/ClientPackets.dart';
|
||||
import 'package:servermanager/structs/settings.dart';
|
||||
|
||||
|
@ -9,7 +10,10 @@ void main() async {
|
|||
ClientPackets.register();
|
||||
// Set up paths
|
||||
Settings settings = Settings();
|
||||
settings.Read();
|
||||
await settings.Read();
|
||||
|
||||
print(
|
||||
"Server Admin Credentials\nUsername: ${settings.serverLoginCreds.username}\nPassword: ${settings.serverLoginCreds.password}");
|
||||
|
||||
PathHelper helper = PathHelper(pth: Directory.current.path);
|
||||
helper = helper.resolve("data").mkdir();
|
||||
|
@ -17,13 +21,38 @@ void main() async {
|
|||
PathHelper steamCmd =
|
||||
PathHelper.builder(helper.build()).resolve("steamcmd").mkdir();
|
||||
PathHelper game = PathHelper.builder(helper.build()).resolve("game").mkdir();
|
||||
PathHelper proton = PathHelper(pth: helper.build()).resolve("proton").mkdir();
|
||||
|
||||
settings.base_path = helper.build();
|
||||
settings.game_path = game.build();
|
||||
settings.steamcmd_path = steamCmd.build();
|
||||
settings.proton_path = proton.build();
|
||||
|
||||
print("Setup of local system variables completed");
|
||||
|
||||
settings.Write();
|
||||
settings.initializeSteamCmd();
|
||||
print("Wrote settings.dat");
|
||||
|
||||
print("Initializing SteamCMD");
|
||||
await settings.initializeSteamCmd();
|
||||
print("Initialized Steamcmd and Proton");
|
||||
|
||||
print("Checking for game server updates...");
|
||||
await settings.RunUpdate();
|
||||
print("Finished checking for game server updates...");
|
||||
|
||||
if (settings.FTS) {
|
||||
print(
|
||||
"Aborting server startup procedure, initial server setup is not yet complete\n\n[ You must log in with the ServerManager to continue ]");
|
||||
} else {
|
||||
print("Downloading mods...");
|
||||
await doDownloadMods(false);
|
||||
|
||||
print("Scanning mods...");
|
||||
settings.inst!.mods = await doScanMods();
|
||||
}
|
||||
|
||||
print("Starting up server manager server wrapper");
|
||||
await PacketServer.start();
|
||||
|
||||
print("Server stopping");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
rm -rf out/*
|
||||
if [ ! -d out ]
|
||||
then
|
||||
mkdir out
|
||||
|
@ -8,4 +7,4 @@ fi
|
|||
|
||||
flutter build linux
|
||||
dart compile exe -o out/server bin/server.dart
|
||||
cp -rv build/linux/x64/release/bundle out/client
|
||||
rsync -a --progress -h --delete build/linux/x64/release/bundle/ out/client/
|
|
@ -5,13 +5,14 @@ import 'package:libac_flutter/utils/IOTools.dart';
|
|||
import 'package:servermanager/structs/mod.dart';
|
||||
import 'package:servermanager/structs/settings.dart';
|
||||
|
||||
Future<void> doDownloadMods(String modsFolder) async {
|
||||
Future<void> doDownloadMods(bool jail) async {
|
||||
Settings settings = Settings();
|
||||
|
||||
if (!settings.inst!.downloadMods) return;
|
||||
|
||||
// Now, invoke SteamCmd to download the workshop mods. This is an authenticated action, and does require Scmd2fa
|
||||
String code = "";
|
||||
|
||||
if (settings.inst!.steam_creds!.has_2fa) {
|
||||
var result = await Process.run(settings.getSteamCmd2FA(),
|
||||
["--raw", "--secret", settings.inst!.steam_creds!.secret]);
|
||||
|
@ -23,7 +24,7 @@ Future<void> doDownloadMods(String modsFolder) async {
|
|||
"+@sSteamCmdForcePlatformType",
|
||||
"windows",
|
||||
"+force_install_dir",
|
||||
modsFolder,
|
||||
jail ? settings.getModJailPath() : settings.getModPath(),
|
||||
"+login",
|
||||
settings.inst!.steam_creds!.username,
|
||||
settings.inst!.steam_creds!.password,
|
||||
|
@ -85,7 +86,7 @@ Future<void> doMigrateMods() async {
|
|||
}
|
||||
}
|
||||
|
||||
Future<List<Mod>> doScanMods(String modsFolder) async {
|
||||
Future<List<Mod>> doScanMods() async {
|
||||
Settings settings = Settings();
|
||||
|
||||
List<Mod> ret = [];
|
||||
|
@ -93,8 +94,7 @@ Future<List<Mod>> doScanMods(String modsFolder) async {
|
|||
for (Mod M in settings.inst!.mods.toList()) {
|
||||
var index = settings.inst!.mods.indexOf(M);
|
||||
// Assemble final path.
|
||||
String modsPath = PathHelper.builder(settings.game_path)
|
||||
.resolve("mods")
|
||||
String modsPath = PathHelper.builder(settings.getModPath())
|
||||
.resolve("steamapps")
|
||||
.resolve("workshop")
|
||||
.resolve("content")
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../game.dart';
|
||||
import '../statemachine.dart';
|
||||
import '../structs/autorestarts.dart';
|
||||
import '../structs/serversettings.dart';
|
||||
|
@ -46,43 +43,6 @@ class GameServerPageState extends State<GameServerPage> {
|
|||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: settings.serverInstalled()
|
||||
? Text("Update / Validate Server Install")
|
||||
: Text("Initial Server Download"),
|
||||
subtitle: settings.serverInstalled()
|
||||
? Text(
|
||||
"Validates game files or performs an update. This is done when starting the server as well.")
|
||||
: Text(
|
||||
"Download the game server. This is step 1, after having downloaded steamcmd."),
|
||||
leading: Icon(Icons.numbers),
|
||||
onTap: () async {
|
||||
if (downloading) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text("Wait until the download completes")));
|
||||
|
||||
return;
|
||||
}
|
||||
if (!settings.isValid()) return;
|
||||
Directory(settings.getServerPath()).createSync();
|
||||
|
||||
setState(() {
|
||||
downloading = true;
|
||||
});
|
||||
|
||||
// Start server download into folder
|
||||
await settings.RunUpdate();
|
||||
|
||||
setState(() {
|
||||
downloading = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (downloading)
|
||||
ListTile(
|
||||
title: Text("Downloading..."),
|
||||
leading: Icon(Icons.downloading),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mods"),
|
||||
leading: Icon(Icons.build),
|
||||
|
@ -97,34 +57,6 @@ class GameServerPageState extends State<GameServerPage> {
|
|||
Navigator.pushNamed(context, "/server/mods");
|
||||
},
|
||||
),
|
||||
if (settings.inst!.downloadMods)
|
||||
ListTile(
|
||||
title: Text("Download Mods"),
|
||||
subtitle: Text("Downloads the mods"),
|
||||
leading: Icon(Icons.download_sharp),
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
downloading = true;
|
||||
});
|
||||
await doDownloadMods(settings.getModPath());
|
||||
|
||||
setState(() {
|
||||
downloading = false;
|
||||
});
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Scanning mods...")));
|
||||
|
||||
var mods = await doScanMods(settings.getModPath());
|
||||
setState(() {
|
||||
settings.inst!.mods = mods;
|
||||
|
||||
settings.Write();
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Mod scanning complete")));
|
||||
},
|
||||
),
|
||||
if (!settings.inst!.downloadMods)
|
||||
ListTile(
|
||||
title: Text("Conan Exiles Install Path"),
|
||||
|
|
|
@ -47,10 +47,10 @@ class StateMachine {
|
|||
Settings settings = Settings();
|
||||
await settings.RunUpdate(valid: false);
|
||||
if (settings.inst!.downloadMods)
|
||||
await doDownloadMods(settings.getModPath());
|
||||
await doDownloadMods(false);
|
||||
else
|
||||
await doMigrateMods();
|
||||
settings.inst!.mods = await doScanMods(settings.getModPath());
|
||||
settings.inst!.mods = await doScanMods();
|
||||
|
||||
await settings.writeOutModListFile();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:archive/archive.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:libac_flutter/nbt/NbtIo.dart';
|
||||
import 'package:libac_flutter/nbt/NbtUtils.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
import 'package:libac_flutter/packets/packets.dart';
|
||||
import 'package:libac_flutter/utils/IOTools.dart';
|
||||
|
@ -21,11 +22,17 @@ class Settings {
|
|||
final String Base2FAPath =
|
||||
"https://github.com/zontreck/steamcmd-2fa/releases/download/0.2.0/steamcmd-2fa";
|
||||
|
||||
final String PROTON_URL =
|
||||
"https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton9-5/GE-Proton9-5.tar.gz";
|
||||
|
||||
Settings._();
|
||||
static final Settings Instance = Settings._();
|
||||
|
||||
String steamcmd_path = "";
|
||||
String game_path = "";
|
||||
String proton_path = "";
|
||||
String base_path = "";
|
||||
bool FTS = true;
|
||||
Credentials serverLoginCreds = Credentials(
|
||||
username: "admin", password: "changeMe123", secret: "", has_2fa: false);
|
||||
UUID remoteLoginToken = UUID.ZERO;
|
||||
|
@ -47,42 +54,44 @@ class Settings {
|
|||
inst = SettingsEntry.deserialize(tag.get("entry") as CompoundTag);
|
||||
serverLoginCreds = Credentials.deserialize(
|
||||
tag.get(Credentials.TAG_NAME)!.asCompoundTag());
|
||||
FTS = NbtUtils.readBoolean(tag, "fts");
|
||||
} catch (E) {
|
||||
print("No existing settings file found, initializing default settings");
|
||||
inst = SettingsEntry();
|
||||
inst!.steam_creds =
|
||||
Credentials(username: "", password: "", secret: "", has_2fa: false);
|
||||
|
||||
serverLoginCreds = Credentials(
|
||||
username: "admin",
|
||||
password: "changeMe123",
|
||||
secret: "",
|
||||
has_2fa: false);
|
||||
FTS = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Write() {
|
||||
if (!isValid()) return;
|
||||
if (inst == null) return;
|
||||
CompoundTag tag = CompoundTag();
|
||||
tag.put("entry", inst!.serialize());
|
||||
tag.put(Credentials.TAG_NAME, serverLoginCreds.save());
|
||||
NbtUtils.writeBoolean(tag, "fts", FTS);
|
||||
|
||||
NbtIo.write("settings.dat", tag);
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
if (inst == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> Open() async {
|
||||
Close();
|
||||
Instance.Read();
|
||||
}
|
||||
|
||||
static void Close() async {
|
||||
if (Instance.isValid()) {
|
||||
Instance.Write();
|
||||
Instance.inst = null;
|
||||
}
|
||||
Instance.Write();
|
||||
Instance.inst = null;
|
||||
}
|
||||
|
||||
String getServerPath() {
|
||||
return "$game_path${Platform.pathSeparator}server";
|
||||
return game_path;
|
||||
}
|
||||
|
||||
bool checkInitDone() {
|
||||
|
@ -97,16 +106,32 @@ class Settings {
|
|||
return "$steamcmd_path${Platform.pathSeparator}steamcmd${Platform.isWindows ? ".exe" : ".sh"}";
|
||||
}
|
||||
|
||||
String getSteamCmdPath() {
|
||||
return steamcmd_path;
|
||||
}
|
||||
|
||||
String getSteamCmd2FA() {
|
||||
return "$steamcmd_path${Platform.pathSeparator}steamcmd-2fa${Platform.isWindows ? ".exe" : ""}";
|
||||
}
|
||||
|
||||
String getModPath() {
|
||||
return "$game_path${Platform.pathSeparator}mods";
|
||||
return PathHelper(pth: base_path).resolve("mods").build();
|
||||
}
|
||||
|
||||
String getModJailPath() {
|
||||
return "$game_path${Platform.pathSeparator}mods.jail";
|
||||
return PathHelper(pth: base_path).resolve("mods.jail").build();
|
||||
}
|
||||
|
||||
String getProtonPath() {
|
||||
return PathHelper(pth: base_path).resolve("proton").build();
|
||||
}
|
||||
|
||||
String getProtonExecutablePath() {
|
||||
return PathHelper(pth: base_path)
|
||||
.resolve("proton")
|
||||
.resolve("GE-Proton9-5")
|
||||
.resolve("proton")
|
||||
.build();
|
||||
}
|
||||
|
||||
Future<void> createModFolderIfNotExists() async {
|
||||
|
@ -195,7 +220,28 @@ class Settings {
|
|||
flush: true, mode: FileMode.writeOnly);
|
||||
}
|
||||
|
||||
Future<void> initializeProton() async {
|
||||
Dio dio = Dio();
|
||||
print("Downloading proton...");
|
||||
final path = PathHelper(pth: getProtonPath()).resolve("proton.tar.gz");
|
||||
await dio.download(PROTON_URL, path.build());
|
||||
|
||||
String oldWD = Directory.current.path;
|
||||
Directory.current = getProtonPath();
|
||||
Process.runSync("tar", ["-xvf", "proton.tar.gz"]);
|
||||
Process.runSync("rm", ["-f", "proton.tar.gz"]);
|
||||
|
||||
Directory.current = oldWD; // Restore the old working directory
|
||||
print("Finished!");
|
||||
}
|
||||
|
||||
Future<void> initializeSteamCmd() async {
|
||||
if (File(PathHelper(pth: getSteamCmdPath()).resolve("cxinit").build())
|
||||
.existsSync()) {
|
||||
print(
|
||||
"Skipping SteamCmd and Proton initialization, already marked as ready");
|
||||
return;
|
||||
}
|
||||
// Yes, Proceed
|
||||
var x = Directory(steamcmd_path);
|
||||
try {
|
||||
|
@ -217,6 +263,8 @@ class Settings {
|
|||
final bytes = File(path).readAsBytesSync();
|
||||
final arc = ZipDecoder().decodeBytes(bytes);
|
||||
|
||||
print("SteamCmd downloaded. Performing initial update");
|
||||
|
||||
for (final file in arc) {
|
||||
final name = file.name;
|
||||
if (file.isFile) {
|
||||
|
@ -232,6 +280,7 @@ class Settings {
|
|||
Process.runSync("echo", ["X", ">", "cxinit"]);
|
||||
|
||||
proc = await Process.start("steamcmd.exe", ["+quit"]);
|
||||
print("Completed.");
|
||||
} else {
|
||||
// Download tgz file
|
||||
final path = "${steamcmd_path}${Platform.pathSeparator}linux.tgz";
|
||||
|
@ -241,6 +290,8 @@ class Settings {
|
|||
final arc = GZipDecoder().decodeBytes(bytes);
|
||||
final arc2 = TarDecoder().decodeBytes(arc);
|
||||
|
||||
print("SteamCmd downloaded. Performing initial update");
|
||||
|
||||
for (final file in arc2) {
|
||||
final name = file.name;
|
||||
if (file.isFile) {
|
||||
|
@ -256,7 +307,10 @@ class Settings {
|
|||
Process.runSync("chmod", ["+x", "linux32/steamcmd"]);
|
||||
Process.runSync("touch", ["cxinit"]);
|
||||
|
||||
proc = await Process.start("./steamcmd.sh", ["+quit"]);
|
||||
Process.runSync("./steamcmd.sh", ["+quit"]);
|
||||
|
||||
print("Completed. Initializing Proton");
|
||||
await initializeProton();
|
||||
}
|
||||
|
||||
Directory.current = Directory(game_path);
|
||||
|
|
Loading…
Reference in a new issue