91 lines
2.7 KiB
Dart
91 lines
2.7 KiB
Dart
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';
|
|
import 'package:servermanager/structs/SessionData.dart';
|
|
import 'package:servermanager/structs/credentials.dart';
|
|
import 'package:servermanager/structs/settings.dart';
|
|
|
|
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(
|
|
"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();
|
|
print("Initialized Steamcmd");
|
|
|
|
print("Running winetricks");
|
|
if (!settings.wineInitialized) {
|
|
await settings.initializeWine();
|
|
settings.wineInitialized = true;
|
|
settings.Write();
|
|
}
|
|
|
|
print("Finished installing needed DLLs");
|
|
|
|
print("Checking for game server updates...");
|
|
await settings.RunUpdate(valid: false);
|
|
await settings.createModFolderIfNotExists();
|
|
await settings.createServerModFolderIfNotExists();
|
|
await settings.createModJailFolderIfNotExists();
|
|
await settings.createBackupsFolderIfNotExists();
|
|
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 {
|
|
try {
|
|
print("Downloading mods...");
|
|
await doDownloadMods(false);
|
|
|
|
print("Scanning mods...");
|
|
settings.inst!.mods = await doScanMods(false);
|
|
settings.Write();
|
|
|
|
print("Starting scheduler...");
|
|
await settings.subsys.startScheduler();
|
|
} catch (E) {
|
|
settings.FTS = true;
|
|
settings.Write();
|
|
}
|
|
}
|
|
|
|
print("Starting up server manager server wrapper");
|
|
|
|
while (!SessionData.shutdownPending) {
|
|
try {
|
|
await PacketServer.start(
|
|
settings.inst?.serverSettings.WrapperPort ?? 25306);
|
|
} catch (E) {}
|
|
}
|
|
|
|
print("Server stopping");
|
|
}
|