ConanServerManager/bin/server.dart

92 lines
2.7 KiB
Dart
Raw Permalink Normal View History

import 'dart:io';
import 'package:libac_dart/packets/packets.dart';
import 'package:libac_dart/utils/IOTools.dart';
import 'package:servermanager/game.dart';
import 'package:servermanager/packets/ClientPackets.dart';
2024-06-16 20:13:35 -07:00
import 'package:servermanager/structs/SessionData.dart';
2024-07-02 16:01:06 -07:00
import 'package:servermanager/structs/credentials.dart';
import 'package:servermanager/structs/settings.dart';
2024-05-22 16:13:19 -07:00
2024-05-25 05:19:59 -07:00
void main() async {
print("Current working directory: ${Directory.current.path}");
print("/!\\ This server is now starting... /!\\\n\n");
ClientPackets.register();
// Set up paths
Settings settings = Settings();
await settings.Read();
print(
2024-08-28 11:30:57 -07:00
"Server Admin Credentials\nUsername: ${settings.superuser.name}\nPassword (Default): changeMe123\n\n");
PathHelper helper = PathHelper(pth: Directory.current.path);
helper = helper.resolve("data").mkdir();
PathHelper steamCmd =
PathHelper.builder(helper.build()).resolve("steamcmd").mkdir();
PathHelper game = PathHelper.builder(helper.build()).resolve("game").mkdir();
settings.base_path = helper.build();
settings.game_path = game.build();
settings.steamcmd_path = steamCmd.build();
print("Setup of local system variables completed");
settings.Write();
print("Wrote settings.dat");
print("Initializing SteamCMD");
await settings.initializeSteamCmd();
2024-06-03 18:33:13 -07:00
print("Initialized Steamcmd");
print("Running winetricks");
2024-08-28 11:30:57 -07:00
if (!settings.wineInitialized) {
await settings.initializeWine();
settings.wineInitialized = true;
settings.Write();
}
2024-06-03 18:33:13 -07:00
print("Finished installing needed DLLs");
print("Checking for game server updates...");
2024-05-25 06:28:52 -07:00
await settings.RunUpdate(valid: false);
2024-05-23 22:18:59 -07:00
await settings.createModFolderIfNotExists();
await settings.createServerModFolderIfNotExists();
await settings.createModJailFolderIfNotExists();
2024-07-01 23:24:06 -07:00
await settings.createBackupsFolderIfNotExists();
2024-05-23 22:18:59 -07:00
await settings.writeOutModListFile();
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 {
2024-05-24 13:48:21 -07:00
try {
print("Downloading mods...");
await doDownloadMods(false);
2024-05-24 13:48:21 -07:00
print("Scanning mods...");
2024-05-25 04:50:28 -07:00
settings.inst!.mods = await doScanMods(false);
2024-05-24 13:48:21 -07:00
settings.Write();
2024-05-23 22:18:59 -07:00
2024-05-24 13:48:21 -07:00
print("Starting scheduler...");
await settings.subsys.startScheduler();
} catch (E) {
settings.FTS = true;
settings.Write();
}
}
print("Starting up server manager server wrapper");
2024-06-03 18:33:13 -07:00
2024-06-16 20:13:35 -07:00
while (!SessionData.shutdownPending) {
try {
await PacketServer.start(
settings.inst?.serverSettings.WrapperPort ?? 25306);
} catch (E) {}
}
2024-05-22 16:13:19 -07:00
print("Server stopping");
}