From 6ab9ce9bb2b17c5308244332e12df484496da9dd Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 6 May 2023 10:36:37 +0200 Subject: [PATCH 1/6] add Swords 'n Magic and Stuff --- README.md | 1 + game_eggs/README.md | 1 + game_eggs/steamcmd_servers/README.md | 4 + .../Swords_'n_Magic_and_Stuff/README.md | 16 +++ .../Swords_'n_Magic_and_Stuff/wrapper | Bin 0 -> 17736 bytes .../Swords_'n_Magic_and_Stuff/wrapper.c | 118 ++++++++++++++++++ 6 files changed, 140 insertions(+) create mode 100644 game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md create mode 100644 game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper create mode 100644 game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c diff --git a/README.md b/README.md index a5914b11..1015b438 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ If you are reading this it looks like you are looking to add an egg to your serv * [Stormworks: Build and Rescue](game_eggs/steamcmd_servers/stormworks) * [Subnautica: Nitrox Mod](game_eggs/steamcmd_servers/subnautica_nitrox_mod) * [Sven Co-op](game_eggs/steamcmd_servers/svencoop) +* [Swords 'n Magic and Stuff](game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff) * [The Forest](game_eggs/steamcmd_servers/the_forest) * [The Isle](game_eggs/steamcmd_servers/the_isle) * [Evrima](game_eggs/steamcmd_servers/the_isle/evrima) diff --git a/game_eggs/README.md b/game_eggs/README.md index 4f7a8eaf..b2a0a890 100644 --- a/game_eggs/README.md +++ b/game_eggs/README.md @@ -176,6 +176,7 @@ * [Stormworks: Build and Rescue](steamcmd_servers/stormworks) * [Subnautica: Nitrox Mod](steamcmd_servers/subnautica_nitrox_mod) * [Sven Co-op](steamcmd_servers/svencoop) +* [Swords 'n Magic and Stuff](steamcmd_servers/Swords_'n_Magic_and_Stuff) * [Team Fortress 2 Classic](steamcmd_servers/team_fortress_2_classic) * [The Forest](steamcmd_servers/the_forest) * [The Isle](steamcmd_servers/the_isle) diff --git a/game_eggs/steamcmd_servers/README.md b/game_eggs/steamcmd_servers/README.md index db8fada8..a2514941 100644 --- a/game_eggs/steamcmd_servers/README.md +++ b/game_eggs/steamcmd_servers/README.md @@ -215,6 +215,10 @@ This is a collection of servers that use SteamCMD to install. [Sven Co-op](svencoop) +## Swords 'n Magic and Stuff + +[Swords 'n Magic and Stuff](Swords_'n_Magic_and_Stuff) + ## Team Fortress 2 Classic [Team Fortress 2 Classic](team_fortress_2_classic) diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md b/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md new file mode 100644 index 00000000..71a8f2bd --- /dev/null +++ b/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md @@ -0,0 +1,16 @@ +# Swords 'n Magic and Stuff + +Grab your friends and set out for adventure in a world of swords, magic, and stuff. Discover tons of cool loot, uncover hidden secrets, and meet new friends and foes along the way. Make your mark and find a place to call home in this cute, multiplayer, open world RPG. + +## Console +Because there is not yet a real console this egg uses a wrapper that prints the log file to the console but it is a continue loop so it will keep sending the contents of the latest log file to the console. The console does not accept any input. + +## Server Ports + + +| Port | default | +|-----------|---------| +| Game | 7777 | +| Query | 27015 | + + diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper b/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper new file mode 100644 index 0000000000000000000000000000000000000000..0bce0609817198ef56276ff48409e3c9a3626013 GIT binary patch literal 17736 zcmeHPe{fvYb-t@bwh(wFupth=yfHQr0j*?%T^lf7$y)n~%Es}p(ggEZ?>w?tMNq0zf1R5)Xxs}*df(CI<@7o&$CN!JN_y3jzfqMi z70rq#y?V-OzMS4XSIIHu@=|?%RW8ctbJ~BVPCbfEzE$bvb^J&06jMkgc zdQ7LtAta_8Pl^fsUe@-?X%{IWF(p|_n}2Rc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^2^bUe~ zo)hGNS4Jbz@$??Jf!^7cQf^*gmeo@X-U_b{YSkMiaEj{~Ea@OvP7 z)RIY4{rImz_ntxmv-mmn{aTOdgJl6PGcTSj)8D7(S4`Pos*4iyO#cd)vwnX5Dp3xc z)TU=Kclu_TKF^n#^7|*&D)0Y)qxJdx3BQ)q^p>*rv)@`ud=D8CVSS!|GwoqPP0QgfL9uGm6L|C8SBTTjdL~2o_bYy*|YQA|-*W$>j#QL9RKvNw~sY4L)-1oGI zBs1DzP&btBLjnA_-8}x%^})VNMSWPcT4nyUtdQ$xS-RZIL}bxRcPWXvWeR1i_;0k1 B4oLt2 literal 0 HcmV?d00001 diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c b/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c new file mode 100644 index 00000000..21d247d3 --- /dev/null +++ b/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void print_latest_log(const char* log_directory) { + DIR *dir; + struct dirent *entry; + time_t latest_time = 0; + char latest_file[256]; + + dir = opendir(log_directory); + if (dir == NULL) { + printf("Error opening directory %s\n", log_directory); + return; + } + + while ((entry = readdir(dir)) != NULL) { + if (strstr(entry->d_name, "SnMDedSrv-") == entry->d_name && + strstr(entry->d_name, ".log") != NULL) { + char filename[256]; + sprintf(filename, "%s/%s", log_directory, entry->d_name); + struct stat file_stat; + stat(filename, &file_stat); + if (file_stat.st_mtime > latest_time) { + latest_time = file_stat.st_mtime; + strcpy(latest_file, filename); + } + } + } + + if (latest_time == 0) { + printf("No log files found in directory %s\n", log_directory); + return; + } + + printf("\nLatest log file: %s\n", latest_file); + + int fd = open(latest_file, O_RDONLY); + if (fd < 0) { + printf("Error opening file %s\n", latest_file); + return; + } + + char buffer[4096]; + int bytes_read; + int last_line_printed = 0; // Flag to check whether we have printed the last line + do { + bytes_read = read(fd, buffer, sizeof(buffer)); + if (bytes_read > 0) { + // Check if the last character is a newline + if (buffer[bytes_read - 1] == '\n') { + fwrite(buffer, 1, bytes_read, stdout); + fflush(stdout); + } else { + // If the last character is not a newline, add one + char* temp = (char*) malloc(bytes_read + 1); + memcpy(temp, buffer, bytes_read); + temp[bytes_read] = '\n'; + fwrite(temp, 1, bytes_read + 1, stdout); + fflush(stdout); + free(temp); + } + last_line_printed = (buffer[bytes_read - 1] == '\n'); + } + } while (bytes_read > 0); + + // If the last line was not printed, print it now + if (!last_line_printed) { + printf("\n"); + } + + close(fd); +} + +int main(int argc, char** argv) { + if (argc < 2) { + printf("Usage: winewrapper wine_path wine_args exe_path exe_args\n"); + return 0; + } + + char* wine_path = argv[1]; + + pid_t pid = fork(); + if (pid == 0) { + char** wine_argv = (char**) malloc(sizeof(char*) * (argc - 1)); + wine_argv[0] = wine_path; + for (int i = 2; i < argc; i++) { + wine_argv[i - 1] = argv[i]; + } + wine_argv[argc - 1] = NULL; + execv(wine_path, wine_argv); + printf("Error launching wine process\n"); + exit(1); + } else if (pid < 0) { + printf("Error forking process\n"); + exit(1); + } + + sleep(30); + + char* log_directory = "/home/container/SNM2020/Saved/Logs"; + print_latest_log(log_directory); + + while (1) { + sleep(1); + print_latest_log(log_directory); + } + + kill(pid, SIGTERM); + + return 0; +} From ab61df9b64952f15f5b9d612ddd694051db22aea Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 6 May 2023 10:37:49 +0200 Subject: [PATCH 2/6] lowercase s --- README.md | 2 +- game_eggs/README.md | 2 +- game_eggs/steamcmd_servers/README.md | 2 +- .../README.md | 0 .../wrapper | Bin .../wrapper.c | 0 6 files changed, 3 insertions(+), 3 deletions(-) rename game_eggs/steamcmd_servers/{Swords_'n_Magic_and_Stuff => swords_'n_Magic_and_Stuff}/README.md (100%) rename game_eggs/steamcmd_servers/{Swords_'n_Magic_and_Stuff => swords_'n_Magic_and_Stuff}/wrapper (100%) rename game_eggs/steamcmd_servers/{Swords_'n_Magic_and_Stuff => swords_'n_Magic_and_Stuff}/wrapper.c (100%) diff --git a/README.md b/README.md index 1015b438..209110a7 100644 --- a/README.md +++ b/README.md @@ -275,7 +275,7 @@ If you are reading this it looks like you are looking to add an egg to your serv * [Stormworks: Build and Rescue](game_eggs/steamcmd_servers/stormworks) * [Subnautica: Nitrox Mod](game_eggs/steamcmd_servers/subnautica_nitrox_mod) * [Sven Co-op](game_eggs/steamcmd_servers/svencoop) -* [Swords 'n Magic and Stuff](game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff) +* [Swords 'n Magic and Stuff](game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff) * [The Forest](game_eggs/steamcmd_servers/the_forest) * [The Isle](game_eggs/steamcmd_servers/the_isle) * [Evrima](game_eggs/steamcmd_servers/the_isle/evrima) diff --git a/game_eggs/README.md b/game_eggs/README.md index b2a0a890..73f78da4 100644 --- a/game_eggs/README.md +++ b/game_eggs/README.md @@ -176,7 +176,7 @@ * [Stormworks: Build and Rescue](steamcmd_servers/stormworks) * [Subnautica: Nitrox Mod](steamcmd_servers/subnautica_nitrox_mod) * [Sven Co-op](steamcmd_servers/svencoop) -* [Swords 'n Magic and Stuff](steamcmd_servers/Swords_'n_Magic_and_Stuff) +* [Swords 'n Magic and Stuff](steamcmd_servers/swords_'n_Magic_and_Stuff) * [Team Fortress 2 Classic](steamcmd_servers/team_fortress_2_classic) * [The Forest](steamcmd_servers/the_forest) * [The Isle](steamcmd_servers/the_isle) diff --git a/game_eggs/steamcmd_servers/README.md b/game_eggs/steamcmd_servers/README.md index a2514941..3bd93bda 100644 --- a/game_eggs/steamcmd_servers/README.md +++ b/game_eggs/steamcmd_servers/README.md @@ -217,7 +217,7 @@ This is a collection of servers that use SteamCMD to install. ## Swords 'n Magic and Stuff -[Swords 'n Magic and Stuff](Swords_'n_Magic_and_Stuff) +[Swords 'n Magic and Stuff](swords_'n_Magic_and_Stuff) ## Team Fortress 2 Classic diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md similarity index 100% rename from game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/README.md rename to game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper similarity index 100% rename from game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper rename to game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper diff --git a/game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c similarity index 100% rename from game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c rename to game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c From 51439f3e5ac1f6e5c302456e9fff58b664cba85c Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 6 May 2023 10:42:36 +0200 Subject: [PATCH 3/6] add egg + readme first start + wrapper timeout. --- .../swords_'n_Magic_and_Stuff/README.md | 7 +- .../egg-swords-n-magic-and-stuff.json | 172 ++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md index 71a8f2bd..e40fd1cc 100644 --- a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md +++ b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/README.md @@ -3,7 +3,12 @@ Grab your friends and set out for adventure in a world of swords, magic, and stuff. Discover tons of cool loot, uncover hidden secrets, and meet new friends and foes along the way. Make your mark and find a place to call home in this cute, multiplayer, open world RPG. ## Console -Because there is not yet a real console this egg uses a wrapper that prints the log file to the console but it is a continue loop so it will keep sending the contents of the latest log file to the console. The console does not accept any input. +Because there is not yet a real console this egg uses a wrapper that prints the log file to the console but it is a continue loop so it will keep sending the contents of the latest log file to the console. The console does not accept any input. + +There is a 30 seconds timeout before the wrapper will try to start the server as it needs to wait until the log file is written and the first lines are writen to that file. + +## first start +Because of the wrapper the first start of the console will show no logs. On first start wait for vcrun2019 to install. Then hit restart. ## Server Ports diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json new file mode 100644 index 00000000..f731ae45 --- /dev/null +++ b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json @@ -0,0 +1,172 @@ +{ + "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", + "meta": { + "version": "PTDL_v2", + "update_url": null + }, + "exported_at": "2023-05-06T10:38:52+02:00", + "name": "Swords 'n Magic and Stuff", + "author": "josdekurk@gmail.com", + "description": "Grab your friends and set out for adventure in a world of swords, magic, and stuff. Discover tons of cool loot, uncover hidden secrets, and meet new friends and foes along the way. Make your mark and find a place to call home in this cute, multiplayer, open world RPG", + "features": null, + "docker_images": { + "ghcr.io\/parkervcp\/yolks:wine_staging": "ghcr.io\/parkervcp\/yolks:wine_staging" + }, + "file_denylist": [], + "startup": ".\/wrapper \/usr\/bin\/wine \/home\/container\/SNM2020\/Binaries\/Win64\/SNMASServer-Win64-Shipping.exe -port={{SERVER_PORT}} -QueryPort={{QUERY_PORT}}", + "config": { + "files": "{}", + "startup": "{\r\n \"done\": \"Succeeded to create Steam session with ID\"\r\n}", + "logs": "{}", + "stop": "^^C" + }, + "scripts": { + "installation": { + "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ghcr.io\/parkervcp\/installers:debian'\r\n\r\n##\r\n#\r\n# Variables\r\n# STEAM_USER, STEAM_PASS, STEAM_AUTH - Steam user setup. If a user has 2fa enabled it will most likely fail due to timeout. Leave blank for anon install.\r\n# WINDOWS_INSTALL - if it's a windows server you want to install set to 1\r\n# SRCDS_APPID - steam app id found here - https:\/\/developer.valvesoftware.com\/wiki\/Dedicated_Servers_List\r\n# SRCDS_BETAID - beta branch of a steam app. Leave blank to install normal branch\r\n# SRCDS_BETAPASS - password for a beta branch should one be required during private or closed testing phases.. Leave blank for no password.\r\n# INSTALL_FLAGS - Any additional SteamCMD flags to pass during install.. Keep in mind that steamcmd auto update process in the docker image might overwrite or ignore these when it performs update on server boot.\r\n# AUTO_UPDATE - Adding this variable to the egg allows disabling or enabling automated updates on boot. Boolean value. 0 to disable and 1 to enable.\r\n#\r\n ##\r\n\r\n# Install packages. Default packages below are not required if using our existing install image thus speeding up the install process.\r\n#apt -y update\r\n#apt -y --no-install-recommends install curl lib32gcc-s1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [[ \"${STEAM_USER}\" == \"\" ]] || [[ \"${STEAM_PASS}\" == \"\" ]]; then\r\n echo -e \"steam user is not set.\\n\"\r\n echo -e \"Using anonymous user.\\n\"\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nelse\r\n echo -e \"user set to ${STEAM_USER}\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\nmkdir -p \/mnt\/server\/steamapps # Fix steamcmd disk write error when this folder is missing\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +force_install_dir \/mnt\/server +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} $( [[ \"${WINDOWS_INSTALL}\" == \"1\" ]] && printf %s '+@sSteamCmdForcePlatformType windows' ) +app_update ${SRCDS_APPID} $( [[ -z ${SRCDS_BETAID} ]] || printf %s \"-beta ${SRCDS_BETAID}\" ) $( [[ -z ${SRCDS_BETAPASS} ]] || printf %s \"-betapassword ${SRCDS_BETAPASS}\" ) ${INSTALL_FLAGS} validate +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so\r\n\r\n## add below your custom commands if needed\r\nmkdir -p \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/\r\n\r\nif [ ! -f \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini ]\r\nthen\r\n echo \"The config file does not yet exists, making a new one\"\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nelse\r\n echo \"Old config file found. Replacing it with a up to date one but a backup will be made\"\r\n mv \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game-$(date \"+%Y.%m.%d-%H.%M.%S\").ini.old\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nfi\r\n\r\nif [ ! -f \/mnt\/server\/wrapper ]\r\nthen\r\n echo \"The wrapper does not yet exists, download a new one\"\r\n curl -sSL -o \/mnt\/server\/wrapper \"https:\/\/raw.githubusercontent.com\/parkervcp\/eggs\/master\/game_eggs\/steamcmd_servers\/swords_'n_Magic_and_Stuff\/wrapper\"\r\n chmod +x wrapper\r\nelse\r\n echo \"wrapper found. skipping\"\r\nfi\r\n\r\n\r\n## install end\r\necho \"-----------------------------------------\"\r\necho \"Installation completed...\"\r\necho \"-----------------------------------------\"", + "container": "ghcr.io\/parkervcp\/installers:debian", + "entrypoint": "bash" + } + }, + "variables": [ + { + "name": "WINDOWS_INSTALL", + "description": "", + "env_variable": "WINDOWS_INSTALL", + "default_value": "1", + "user_viewable": false, + "user_editable": false, + "rules": "required|boolean", + "field_type": "text" + }, + { + "name": "App id", + "description": "", + "env_variable": "SRCDS_APPID", + "default_value": "2058450", + "user_viewable": false, + "user_editable": false, + "rules": "required|string|max:20", + "field_type": "text" + }, + { + "name": "Auto update", + "description": "Auto update the server on startup", + "env_variable": "AUTO_UPDATE", + "default_value": "1", + "user_viewable": true, + "user_editable": true, + "rules": "required|boolean", + "field_type": "text" + }, + { + "name": "WINEARCH", + "description": "", + "env_variable": "WINEARCH", + "default_value": "win64", + "user_viewable": false, + "user_editable": false, + "rules": "required|string|in:win32,win64", + "field_type": "text" + }, + { + "name": "WINEDEBUG", + "description": "", + "env_variable": "WINEDEBUG", + "default_value": "-all", + "user_viewable": false, + "user_editable": false, + "rules": "required|string|max:32", + "field_type": "text" + }, + { + "name": "WINETRICKS_RUN", + "description": "", + "env_variable": "WINETRICKS_RUN", + "default_value": "vcrun2019", + "user_viewable": false, + "user_editable": false, + "rules": "required|string|max:64", + "field_type": "text" + }, + { + "name": "Query port", + "description": "The port that Steam uses for clients to query the server (ping, etc)", + "env_variable": "QUERY_PORT", + "default_value": "27015", + "user_viewable": true, + "user_editable": false, + "rules": "required|string|", + "field_type": "text" + }, + { + "name": "Server name", + "description": "This is the server name used for your server.\r\n\r\nYou must pick between 2 and 5 UNIQUE words (no duplicate words).\r\nThe words are case insensitive \r\nThe list of approved words changes can be found: `SNM2020\/Saved\/Logs\/Allowed-Words.txt`", + "env_variable": "SNM_NAME", + "default_value": "", + "user_viewable": true, + "user_editable": true, + "rules": "nullable|string|max:64", + "field_type": "text" + }, + { + "name": "Admin steam id", + "description": "This the Steam ID of the owner\/admin of this server.", + "env_variable": "SNM_OWNER_STEAM_ID", + "default_value": "", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:20", + "field_type": "text" + }, + { + "name": "Server password", + "description": "This is the server password; it is disabled by default.", + "env_variable": "SNM_PASSWORD", + "default_value": "", + "user_viewable": true, + "user_editable": true, + "rules": "nullable|string|max:32", + "field_type": "text" + }, + { + "name": "Max players", + "description": "You can specify the maximum number of players", + "env_variable": "SNM_MAX_PLAYERS", + "default_value": "16", + "user_viewable": true, + "user_editable": false, + "rules": "required|string|max:16", + "field_type": "text" + }, + { + "name": "Reset time", + "description": "This is the number of days between resets.", + "env_variable": "SNM_DAYS_UNTIL_RESET", + "default_value": "1", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:20", + "field_type": "text" + }, + { + "name": "Reset time", + "description": "This is the local time of day when the server will\r\nreset. The format is HH:MM, and it is 24 hour format.\r\nMidnight => 00:00, 10:30AM => 10:30, 4:30PM => 16:30", + "env_variable": "SNM_RESET_TIME_OF_DAY", + "default_value": "00:00", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:20", + "field_type": "text" + }, + { + "name": "logs dir", + "description": "", + "env_variable": "LOGS_DIR", + "default_value": "\/home\/container\/SNM2020\/Saved\/Logs", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|", + "field_type": "text" + } + ] +} \ No newline at end of file From bf1217839dbbcb4c344072de1c68763b37e7914a Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 6 May 2023 11:31:33 +0200 Subject: [PATCH 4/6] Improve wrapper --- .../swords_'n_Magic_and_Stuff/wrapper | Bin 17736 -> 17784 bytes .../swords_'n_Magic_and_Stuff/wrapper.c | 74 +++++++++++------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper index 0bce0609817198ef56276ff48409e3c9a3626013..29909ad1d2164be05bc25be8c4b4a78a59e5e7e9 100644 GIT binary patch delta 3064 zcmZWr4Qx}_6~5Pw6Wb-&j^j9n(AcyiNegit8cd>@*bpy|iM62CU8Md%R>}(P*3gn| znUXrx4eG0FN;uH96lsaHu0qpPm{*3{v^Yh@$<|h8+8D4@O{YzIS%D=Qpo}JaJLkUl zvaWm5d*|MBzVmy}yZ4U0z-M3J2P$1dE+(F+M%e6N-5a(JyEf|>yco2NmuQo5aPgpR z$fV7NU?UIOr}Y^#!?S#!t303y7by5l@080euXVAxKet~x)zNx!*VfV^_p*6VOt*WM zBAVk{EVTCG#L1RIz+A(B2AyUvY%^Dye$OD;=z*8aA^r%AnuD;ps1nBTwH8(Kg9I~O z6%Z3k(2O4ws{JT^P>hb_=tp8SS=7KEr;%x1*XVQQ@CiHNsLzmqW}{4(BX) zTb_9O(MKPLTZ=EjjpF*q36wc?+@ZmjF>*6|N9T1f*=b|U#Lnt+C87-syZz8v;`K$# zG;SgKztRE>mfXp2fp-zJNE3jIiKapmLOw~d5|}C;NPmMe(gK;jO{p}K^Y5O*(jfTSd#xDrT#j- z`MymV%iqzulqpRK5>d^Jsh$edx#p;DBT0m#K`CRoi9D%!c8^C&TduCc@jz~mO`UX9 z_mk~2I+g61$T>o0ntlskxT@Md(4kg!a)+>JAp0Y)B93(j6H+Sjb3`#o{@b2KQabV! z@|9H>yYd)*&RTZE17(5aH1@J2zgv4%RVDc?zaWPziR9z66oQl<(1dyA*YgC5D^jXY zVUB?dUzVQ5lvb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V(%2mLta;cR_Npr8{f z^sxFlOWeA?L7$Of?*QK4f^p*hYUiignMv*{%2SLE{ef~^_9HJgWbuH~t_hfG7!Tyw z`LW_M6Du(yd>u05kto1Oz-8u02YeE6(+zMp&_??p8gxS>SZQ`3el+N(b#ON5rpNH< zg7<>YV6z4`yUbpagM*vf+Ozskg%Nud4oqYfSy*BB>2_nq41Nd)lz7QB+}iA?-Qat0 zKm7~zKj^1U7{PHJ@QpR}F=%eA_8QA&thN&eWu{fc2}c|EdyPZXXpWnR3dBRQFxS|I zZzHh9&kM$a>*>eg=$1D659n`nd*_kwWc-Lxn(_ALG{zKXK{>7|V&P zX3SYPlh^eey?TGD8v?;Mb^9)t##A=~4$rA}!<#^I3rDZ2^;}n<^Xz&560+FbS7x*0 zK`21fR8H5yCrxh1Hx=QVD>sq2sydrJv}ZKhJVr+=zO&9ex@GHHN{8WxEq>nUR73Lc zGFpv3HDnXawD>te-xLDykr3CRYaI}egvyM4W5@!9S0c~a4&bt}3&tXD2t|3WPw&P) zh(|*pMxCZX3%nAo=ZuCBU@F>1H-dMYpZotWZG2mZJLc139UC3m)<&`W`_1KWWBVE| t8_|F)@U0=vSeqQgTU)T(hFV*=LW9PLzzi~)nl #include -void print_latest_log(const char* log_directory) { +void print_latest_log(const char* log_directory, off_t* last_pos, off_t* last_size) { DIR *dir; struct dirent *entry; time_t latest_time = 0; @@ -39,45 +39,58 @@ void print_latest_log(const char* log_directory) { return; } - printf("\nLatest log file: %s\n", latest_file); - int fd = open(latest_file, O_RDONLY); if (fd < 0) { printf("Error opening file %s\n", latest_file); return; } - char buffer[4096]; - int bytes_read; - int last_line_printed = 0; // Flag to check whether we have printed the last line - do { - bytes_read = read(fd, buffer, sizeof(buffer)); - if (bytes_read > 0) { - // Check if the last character is a newline - if (buffer[bytes_read - 1] == '\n') { - fwrite(buffer, 1, bytes_read, stdout); - fflush(stdout); - } else { - // If the last character is not a newline, add one - char* temp = (char*) malloc(bytes_read + 1); - memcpy(temp, buffer, bytes_read); - temp[bytes_read] = '\n'; - fwrite(temp, 1, bytes_read + 1, stdout); - fflush(stdout); - free(temp); + // Get the size of the file + off_t size = lseek(fd, 0, SEEK_END); + + // Check if the file size has increased since the last read + if (size > *last_size) { + // Move the file pointer to the beginning of the file + lseek(fd, 0, SEEK_SET); + + char buffer[4096]; + int bytes_read; + int last_line_printed = 0; // Flag to check whether we have printed the last line + do { + bytes_read = read(fd, buffer, sizeof(buffer)); + if (bytes_read > 0) { + // Check if the last character is a newline + if (buffer[bytes_read - 1] == '\n') { + fwrite(buffer, 1, bytes_read, stdout); + fflush(stdout); + } else { + // If the last character is not a newline, add one + char* temp = (char*) malloc(bytes_read + 1); + memcpy(temp, buffer, bytes_read); + temp[bytes_read] = '\n'; + fwrite(temp, 1, bytes_read + 1, stdout); + fflush(stdout); + free(temp); + } + last_line_printed = (buffer[bytes_read - 1] == '\n'); } - last_line_printed = (buffer[bytes_read - 1] == '\n'); + } while (bytes_read > 0); + + // If the last line was not printed, print it now + if (!last_line_printed) { + printf("\n"); } - } while (bytes_read > 0); - // If the last line was not printed, print it now - if (!last_line_printed) { - printf("\n"); + // Remember the last position and size that was read + *last_pos = lseek(fd, 0, SEEK_CUR); + *last_size = size; } - close(fd); + } + + int main(int argc, char** argv) { if (argc < 2) { printf("Usage: winewrapper wine_path wine_args exe_path exe_args\n"); @@ -104,12 +117,15 @@ int main(int argc, char** argv) { sleep(30); + off_t last_pos = 0; + off_t last_size = 0; char* log_directory = "/home/container/SNM2020/Saved/Logs"; - print_latest_log(log_directory); + print_latest_log(log_directory, &last_pos, &last_size); + while (1) { sleep(1); - print_latest_log(log_directory); + print_latest_log(log_directory, &last_pos, &last_size); } kill(pid, SIGTERM); From 9c08f3fd5ef42c32765c732da43ce08cbc9eddbd Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 6 May 2023 11:38:55 +0200 Subject: [PATCH 5/6] wrapper use time and not size --- .../swords_'n_Magic_and_Stuff/wrapper | Bin 17784 -> 17784 bytes .../swords_'n_Magic_and_Stuff/wrapper.c | 79 +++++++++--------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper index 29909ad1d2164be05bc25be8c4b4a78a59e5e7e9..dc959e19edd2d38aa7e0fd37c49ba270a18afaac 100644 GIT binary patch delta 1199 zcmZ8fTS!z<6g_7~ZM1Y|%t!X}K}1oRy%mxg>eA^&Wla&)M+JTO6Bd35P9sbfx7+P? z8Y&`?3j2w&rX&R)DLGnEx1Sio0sFgUCX~ixqo=*kb^P$cWuLRx+H0?~&xu{4u}iec zK~r015c#!)+_al!or&xlstR;OD<0oCd9UU0ykq5E)gjaNHpBTPnGmL@pOvBf7k}-3 zw{;*Ba%x-YkPu9LSt3Jl35Ku|Ls_QPTVU9HF^(j~WC5Q^ob{0e%8kri+Q-eziX)P$ z*BdCHuQO+%c=#3Sm|?8egPSE}G1Sk1n#D=7%WVY8l$dW3w3HiFi9vy-Rd4X%>@|MN zN)OY^D?!^5ZioxU(z!-Z$9bg{b6{pdh<3CvWn}^?RHZ-Q>nAk@lMJS!YUz~f z4pgnNROMJSho<=ZTP>jv;JXYMVP!-nblvzVgr)%Q!bS;PRU!djggCE6fu_O6r0lk{ z`Ft|cH>OpuW?FjLatX1M23mo9J9I^}=0)hhwB$KJz-?*VFT`Li%5;JZrgD&>DhA|a zy|lqJ#Q+P4_xwXw62l}ldPo|y3@@|XfDCj6WU6Jh)v^%?iF!*eYdC3VhiMKl-P_Cb-8h+n$w3CdvejX$?Cae*opAyf zgVDb3Q_lSJs7E}9cIo9$7sKMz-#liR5T+a(O)4cm5Lg3q)|3`={I9e^lqYy9i!-aPjtg>T+4A%wQmh=?+a{H_q z4l*B7weUA`cTqkid{xo5yg8#n;9L?PJWdja-xa!Ebaf_e3KbUbNrF(ddXtSd@Mmiu z=eWRT{Nr}R)Nb@4l%m8ngW LI!&QZo=5ioph^Kt;1!}3>#DW3Qd)fQ$xxyMvaGO1 zypH1!W3<+S`s9;z>u4&XW@^AS8f5ztY}`;^gt1Ds7-idT9KUlXn+FGmGxwbDeBXD@ z-Yp#Fg~L1(;uZZ9nR@!|DDUG_eqqZBkR~`N<$e1vz z(ke82)^E}KYhFf?lQ--C_BIF3T zTwRXUJ>}DsZ{?0Kn|FiTCq7^Fyr+2%5(vNbyjvtUE*pca)br_No^`~>5JD0|>o~*L z#PA~+3_X86fNn(rYY7xEaSo2uPErPg#a#I4cVl3ZDuEjS&gvtS5~fMEiH=3c%ma{7 zUFrkrqL!&B*Z*yc9`CAa9f!uv5@?!);K+w4! z$7h{H{lb)N4AG*CrlTr%h@o&o^< zDMjG(W!<6w6xn+-giku*9!KgUYS3e^@Qb9ABdoo$w-RHxS5;H~I?Ytt+&{<(qdQJF zKn6<7HWE1@BiJE){|Q8YUt+0{Pel6pMwz@JWP2u^yunk`@Kas@wc81dx)D#;fE*?> z!e|L$8!z29>%|9gp0gs;_NRJD%xsQQi~XS4A^etf1}akA<1IE6nw@!N+3@-;0I&3QbBkvEhA00*GhB{e8RUhi4ri zLbmI;wzbu4J~x*!ZOb}2s3q3P*V<-H78An!=s41!w>FGo4d@tQ z3$Oio#PjG1Hooz^shI2t;ts^0tS@Gtow>3MC9OJgFtEC6LfNvi$rD3t22!1PZ7W(g zi$|;lb!%(uUwa;{rS#wqvm)NOeWLEzB<|R==YLj?(6(?@fM={<7G118U*m&IZ4rFL z0@W;IwJm-D=r>E6IB&7eG@Xtr7eL>}UoFO}S)Z*f-CDup)*0>N3TKSRv47Vtmc0W+ CyC%~B diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c index 7c94477b..c38eadb5 100644 --- a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c +++ b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c @@ -8,7 +8,7 @@ #include #include -void print_latest_log(const char* log_directory, off_t* last_pos, off_t* last_size) { +void print_latest_log(const char* log_directory, off_t* last_pos, time_t* last_time) { DIR *dir; struct dirent *entry; time_t latest_time = 0; @@ -39,58 +39,57 @@ void print_latest_log(const char* log_directory, off_t* last_pos, off_t* last_si return; } + if (latest_time <= *last_time) { + return; + } + int fd = open(latest_file, O_RDONLY); if (fd < 0) { printf("Error opening file %s\n", latest_file); return; } - // Get the size of the file - off_t size = lseek(fd, 0, SEEK_END); + // Move the file pointer to the last printed position + lseek(fd, *last_pos, SEEK_SET); - // Check if the file size has increased since the last read - if (size > *last_size) { - // Move the file pointer to the beginning of the file - lseek(fd, 0, SEEK_SET); - - char buffer[4096]; - int bytes_read; - int last_line_printed = 0; // Flag to check whether we have printed the last line - do { - bytes_read = read(fd, buffer, sizeof(buffer)); - if (bytes_read > 0) { - // Check if the last character is a newline - if (buffer[bytes_read - 1] == '\n') { - fwrite(buffer, 1, bytes_read, stdout); - fflush(stdout); - } else { - // If the last character is not a newline, add one - char* temp = (char*) malloc(bytes_read + 1); - memcpy(temp, buffer, bytes_read); - temp[bytes_read] = '\n'; - fwrite(temp, 1, bytes_read + 1, stdout); - fflush(stdout); - free(temp); - } - last_line_printed = (buffer[bytes_read - 1] == '\n'); + char buffer[4096]; + int bytes_read; + int last_line_printed = 0; // Flag to check whether we have printed the last line + do { + bytes_read = read(fd, buffer, sizeof(buffer)); + if (bytes_read > 0) { + // Check if the last character is a newline + if (buffer[bytes_read - 1] == '\n') { + fwrite(buffer, 1, bytes_read, stdout); + fflush(stdout); + } else { + // If the last character is not a newline, add one + char* temp = (char*) malloc(bytes_read + 1); + memcpy(temp, buffer, bytes_read); + temp[bytes_read] = '\n'; + fwrite(temp, 1, bytes_read + 1, stdout); + fflush(stdout); + free(temp); } - } while (bytes_read > 0); - - // If the last line was not printed, print it now - if (!last_line_printed) { - printf("\n"); + last_line_printed = (buffer[bytes_read - 1] == '\n'); } + } while (bytes_read > 0); - // Remember the last position and size that was read - *last_pos = lseek(fd, 0, SEEK_CUR); - *last_size = size; + // If the last line was not printed, print it now + if (!last_line_printed) { + printf("\n"); } - close(fd); + // Remember the last position and time that was read + *last_pos = lseek(fd, 0, SEEK_CUR); + *last_time = latest_time; + + close(fd); } + int main(int argc, char** argv) { if (argc < 2) { printf("Usage: winewrapper wine_path wine_args exe_path exe_args\n"); @@ -116,13 +115,13 @@ int main(int argc, char** argv) { } sleep(30); - + off_t last_pos = 0; off_t last_size = 0; char* log_directory = "/home/container/SNM2020/Saved/Logs"; print_latest_log(log_directory, &last_pos, &last_size); - + while (1) { sleep(1); print_latest_log(log_directory, &last_pos, &last_size); @@ -131,4 +130,4 @@ int main(int argc, char** argv) { kill(pid, SIGTERM); return 0; -} +} \ No newline at end of file From b8adc9556e98650034bf20d5f57369a25e645546 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:31:45 +0200 Subject: [PATCH 6/6] Update: Swords 'n Magic and Stuff --- .../egg-swords-n-magic-and-stuff.json | 18 +-- .../swords_'n_Magic_and_Stuff/wrapper | Bin 17784 -> 0 bytes .../swords_'n_Magic_and_Stuff/wrapper.c | 133 ------------------ 3 files changed, 4 insertions(+), 147 deletions(-) delete mode 100644 game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper delete mode 100644 game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json index f731ae45..0e9cd8f5 100644 --- a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json +++ b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/egg-swords-n-magic-and-stuff.json @@ -4,16 +4,16 @@ "version": "PTDL_v2", "update_url": null }, - "exported_at": "2023-05-06T10:38:52+02:00", + "exported_at": "2023-08-10T18:31:24+02:00", "name": "Swords 'n Magic and Stuff", "author": "josdekurk@gmail.com", "description": "Grab your friends and set out for adventure in a world of swords, magic, and stuff. Discover tons of cool loot, uncover hidden secrets, and meet new friends and foes along the way. Make your mark and find a place to call home in this cute, multiplayer, open world RPG", "features": null, "docker_images": { - "ghcr.io\/parkervcp\/yolks:wine_staging": "ghcr.io\/parkervcp\/yolks:wine_staging" + "Wine": "ghcr.io\/parkervcp\/yolks:wine_latest" }, "file_denylist": [], - "startup": ".\/wrapper \/usr\/bin\/wine \/home\/container\/SNM2020\/Binaries\/Win64\/SNMASServer-Win64-Shipping.exe -port={{SERVER_PORT}} -QueryPort={{QUERY_PORT}}", + "startup": "wine \/home\/container\/SNM2020\/Binaries\/Win64\/SNMASServer-Win64-Shipping.exe -port={{SERVER_PORT}} -QueryPort={{QUERY_PORT}} -log", "config": { "files": "{}", "startup": "{\r\n \"done\": \"Succeeded to create Steam session with ID\"\r\n}", @@ -22,7 +22,7 @@ }, "scripts": { "installation": { - "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ghcr.io\/parkervcp\/installers:debian'\r\n\r\n##\r\n#\r\n# Variables\r\n# STEAM_USER, STEAM_PASS, STEAM_AUTH - Steam user setup. If a user has 2fa enabled it will most likely fail due to timeout. Leave blank for anon install.\r\n# WINDOWS_INSTALL - if it's a windows server you want to install set to 1\r\n# SRCDS_APPID - steam app id found here - https:\/\/developer.valvesoftware.com\/wiki\/Dedicated_Servers_List\r\n# SRCDS_BETAID - beta branch of a steam app. Leave blank to install normal branch\r\n# SRCDS_BETAPASS - password for a beta branch should one be required during private or closed testing phases.. Leave blank for no password.\r\n# INSTALL_FLAGS - Any additional SteamCMD flags to pass during install.. Keep in mind that steamcmd auto update process in the docker image might overwrite or ignore these when it performs update on server boot.\r\n# AUTO_UPDATE - Adding this variable to the egg allows disabling or enabling automated updates on boot. Boolean value. 0 to disable and 1 to enable.\r\n#\r\n ##\r\n\r\n# Install packages. Default packages below are not required if using our existing install image thus speeding up the install process.\r\n#apt -y update\r\n#apt -y --no-install-recommends install curl lib32gcc-s1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [[ \"${STEAM_USER}\" == \"\" ]] || [[ \"${STEAM_PASS}\" == \"\" ]]; then\r\n echo -e \"steam user is not set.\\n\"\r\n echo -e \"Using anonymous user.\\n\"\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nelse\r\n echo -e \"user set to ${STEAM_USER}\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\nmkdir -p \/mnt\/server\/steamapps # Fix steamcmd disk write error when this folder is missing\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +force_install_dir \/mnt\/server +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} $( [[ \"${WINDOWS_INSTALL}\" == \"1\" ]] && printf %s '+@sSteamCmdForcePlatformType windows' ) +app_update ${SRCDS_APPID} $( [[ -z ${SRCDS_BETAID} ]] || printf %s \"-beta ${SRCDS_BETAID}\" ) $( [[ -z ${SRCDS_BETAPASS} ]] || printf %s \"-betapassword ${SRCDS_BETAPASS}\" ) ${INSTALL_FLAGS} validate +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so\r\n\r\n## add below your custom commands if needed\r\nmkdir -p \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/\r\n\r\nif [ ! -f \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini ]\r\nthen\r\n echo \"The config file does not yet exists, making a new one\"\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nelse\r\n echo \"Old config file found. Replacing it with a up to date one but a backup will be made\"\r\n mv \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game-$(date \"+%Y.%m.%d-%H.%M.%S\").ini.old\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nfi\r\n\r\nif [ ! -f \/mnt\/server\/wrapper ]\r\nthen\r\n echo \"The wrapper does not yet exists, download a new one\"\r\n curl -sSL -o \/mnt\/server\/wrapper \"https:\/\/raw.githubusercontent.com\/parkervcp\/eggs\/master\/game_eggs\/steamcmd_servers\/swords_'n_Magic_and_Stuff\/wrapper\"\r\n chmod +x wrapper\r\nelse\r\n echo \"wrapper found. skipping\"\r\nfi\r\n\r\n\r\n## install end\r\necho \"-----------------------------------------\"\r\necho \"Installation completed...\"\r\necho \"-----------------------------------------\"", + "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ghcr.io\/parkervcp\/installers:debian'\r\n\r\n##\r\n#\r\n# Variables\r\n# STEAM_USER, STEAM_PASS, STEAM_AUTH - Steam user setup. If a user has 2fa enabled it will most likely fail due to timeout. Leave blank for anon install.\r\n# WINDOWS_INSTALL - if it's a windows server you want to install set to 1\r\n# SRCDS_APPID - steam app id found here - https:\/\/developer.valvesoftware.com\/wiki\/Dedicated_Servers_List\r\n# SRCDS_BETAID - beta branch of a steam app. Leave blank to install normal branch\r\n# SRCDS_BETAPASS - password for a beta branch should one be required during private or closed testing phases.. Leave blank for no password.\r\n# INSTALL_FLAGS - Any additional SteamCMD flags to pass during install.. Keep in mind that steamcmd auto update process in the docker image might overwrite or ignore these when it performs update on server boot.\r\n# AUTO_UPDATE - Adding this variable to the egg allows disabling or enabling automated updates on boot. Boolean value. 0 to disable and 1 to enable.\r\n#\r\n ##\r\n\r\n# Install packages. Default packages below are not required if using our existing install image thus speeding up the install process.\r\n#apt -y update\r\n#apt -y --no-install-recommends install curl lib32gcc-s1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [[ \"${STEAM_USER}\" == \"\" ]] || [[ \"${STEAM_PASS}\" == \"\" ]]; then\r\n echo -e \"steam user is not set.\\n\"\r\n echo -e \"Using anonymous user.\\n\"\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nelse\r\n echo -e \"user set to ${STEAM_USER}\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\nmkdir -p \/mnt\/server\/steamapps # Fix steamcmd disk write error when this folder is missing\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +force_install_dir \/mnt\/server +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} $( [[ \"${WINDOWS_INSTALL}\" == \"1\" ]] && printf %s '+@sSteamCmdForcePlatformType windows' ) +app_update ${SRCDS_APPID} $( [[ -z ${SRCDS_BETAID} ]] || printf %s \"-beta ${SRCDS_BETAID}\" ) $( [[ -z ${SRCDS_BETAPASS} ]] || printf %s \"-betapassword ${SRCDS_BETAPASS}\" ) ${INSTALL_FLAGS} validate +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so\r\n\r\n## add below your custom commands if needed\r\nmkdir -p \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/\r\n\r\nif [ ! -f \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini ]\r\nthen\r\n echo \"The config file does not yet exists, making a new one\"\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nelse\r\n echo \"Old config file found. Replacing it with a up to date one but a backup will be made\"\r\n mv \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game-$(date \"+%Y.%m.%d-%H.%M.%S\").ini.old\r\n mv \/mnt\/server\/SNM2020\/Content\/Docs\/Dedicated-Server-Game.ini \/mnt\/server\/SNM2020\/Saved\/Config\/WindowsServer\/Game.ini\r\nfi\r\n\r\n\r\n## install end\r\necho \"-----------------------------------------\"\r\necho \"Installation completed...\"\r\necho \"-----------------------------------------\"", "container": "ghcr.io\/parkervcp\/installers:debian", "entrypoint": "bash" } @@ -157,16 +157,6 @@ "user_editable": true, "rules": "required|string|max:20", "field_type": "text" - }, - { - "name": "logs dir", - "description": "", - "env_variable": "LOGS_DIR", - "default_value": "\/home\/container\/SNM2020\/Saved\/Logs", - "user_viewable": true, - "user_editable": true, - "rules": "required|string|", - "field_type": "text" } ] } \ No newline at end of file diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper deleted file mode 100644 index dc959e19edd2d38aa7e0fd37c49ba270a18afaac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17784 zcmeHPeQ;dWb-$~{wlMZe_$vZCctbEX6s;r&TpMs%$y)oFk&R z4?$hy{ni49O%jo+M=w`sH+5520>sW3UXw@VMNq0zZ;g}IYTOMcDE-%*SRpp|D9@hRdwd+xAa*awar{l+TQtJr{1SRbk!K62( z^*HWKC&(crrW{X-3H@Htc1vkHDIqZ>SxTFKo(fZb!51VujdmzlFlD_jLy!FYtckVe*BfiJJ-CNCcnuCvPUwMNS>R4=wke+T%Fg~z|>0&kXZitCziZv zz0pVca_Rd3=anhAy#oFgaBmrTYR__ZZmocaD&SwNfZtaEPgKCyR=}UGfS(8M#ji9` z#LJ!64=do*p5^54uYgm#m6IQ+fZtdFud9IXu7FH z__g9XG44kOiN}Fq zbSf#jzt)fyE^qGLxxbB4zdkBQepPum~Oigc?vtm-kAszGFk% zT62Z3<@REBh3^hwZrHZb3|k4SCz4EAiESI#M&mJSTd*riMtb_TvaqGbgUrW!d0 z(9!;nMh81jc_quJim(g#kC5f@?U`>pi{Zm9{#Ik@>myf_-f1N+c>L$~+NV3iq@Eub z_iKF2uM`<)e*7MV(^%zJS$UkW;n&#koDH92!zXR{A{#zs!+8#-V(xD=m(qC2sll&u zG>y`=$jR$hIl?J|oR<4lj&Pn+2x<1yQ3%52d@VU4R{2$ia5X+F-fzRHjFaJ4Il?%0 zglzWHQQ1es6w?mB%96akg^<95HhiuU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0f@N*vgJgEKTIM)+iGu?lh z-%3I(Jy~7>zZT$j2{Mr#s+}i$OJ)ZEh=RW~X z@}=$jBQ3vQH=2BQ3|lX2{HVSWlh2HSk4oHGCvoEy@N*ULOBL{X+%QqQl=`^@xOaNB zVkPi${mlS=V;T8S1^ILZ{6GaB;F%7um5{*_Iw8#keyi(Y{5P>pSji zYwa-aTeog&V4JzEwXGvSR^{%VP%*ITk2B5DJe12WC7WKz2+ zcYm4DV9H9SOnS>Fw`9=^L5GUoCFa0rGnoTWJHQ-}X<~yG_c+?QRdzd;+$dI}XWumD zD3aUO90To{lXWErz~GjEbZ$`N3i2G64p>_ z+lIzeut&(U-XONq`ND%S*i#gHr`3*AoYu zvIcOZYaBvx*=K!LufD2#!!W{}QdO6?(%?L52=+xns6L(|%W#hRz7K6Jd>CN*Fm99? z`Tl1Rt^YBl;vPsPUMDf-^}jBbvYaRSMf_+f!}`3QVtNw^*%HsE46Q`QuFvZ(rd}4* zv{b(xI9}1xbSo3D&zLUPI6tT0=K&fPn~HLxo$9`)mx#yKcSfAJFOgmUm)6)8n1Gnq*dY-BOH`M-SO>tLv*8evYP!q8}uQU1YHcV*$xfxlH z`_FUGB@x!==MCdc0Fjm}QarLgQ?)L=qA&bfv{}(JMNO4qJ*J-kw%5<=qBB~b{bVz& z$NaC5A*|@XUzLo1M*YhWr~0+HQpS<>f2)Y7j1H&NA%uADdrCqdTNK@)9j1B6hadaT o<1bww?7PxX#~rH`{bora*Uz%Fd@2!R diff --git a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c b/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c deleted file mode 100644 index c38eadb5..00000000 --- a/game_eggs/steamcmd_servers/swords_'n_Magic_and_Stuff/wrapper.c +++ /dev/null @@ -1,133 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void print_latest_log(const char* log_directory, off_t* last_pos, time_t* last_time) { - DIR *dir; - struct dirent *entry; - time_t latest_time = 0; - char latest_file[256]; - - dir = opendir(log_directory); - if (dir == NULL) { - printf("Error opening directory %s\n", log_directory); - return; - } - - while ((entry = readdir(dir)) != NULL) { - if (strstr(entry->d_name, "SnMDedSrv-") == entry->d_name && - strstr(entry->d_name, ".log") != NULL) { - char filename[256]; - sprintf(filename, "%s/%s", log_directory, entry->d_name); - struct stat file_stat; - stat(filename, &file_stat); - if (file_stat.st_mtime > latest_time) { - latest_time = file_stat.st_mtime; - strcpy(latest_file, filename); - } - } - } - - if (latest_time == 0) { - printf("No log files found in directory %s\n", log_directory); - return; - } - - if (latest_time <= *last_time) { - return; - } - - int fd = open(latest_file, O_RDONLY); - if (fd < 0) { - printf("Error opening file %s\n", latest_file); - return; - } - - // Move the file pointer to the last printed position - lseek(fd, *last_pos, SEEK_SET); - - char buffer[4096]; - int bytes_read; - int last_line_printed = 0; // Flag to check whether we have printed the last line - do { - bytes_read = read(fd, buffer, sizeof(buffer)); - if (bytes_read > 0) { - // Check if the last character is a newline - if (buffer[bytes_read - 1] == '\n') { - fwrite(buffer, 1, bytes_read, stdout); - fflush(stdout); - } else { - // If the last character is not a newline, add one - char* temp = (char*) malloc(bytes_read + 1); - memcpy(temp, buffer, bytes_read); - temp[bytes_read] = '\n'; - fwrite(temp, 1, bytes_read + 1, stdout); - fflush(stdout); - free(temp); - } - last_line_printed = (buffer[bytes_read - 1] == '\n'); - } - } while (bytes_read > 0); - - // If the last line was not printed, print it now - if (!last_line_printed) { - printf("\n"); - } - - // Remember the last position and time that was read - *last_pos = lseek(fd, 0, SEEK_CUR); - *last_time = latest_time; - - close(fd); -} - - - - -int main(int argc, char** argv) { - if (argc < 2) { - printf("Usage: winewrapper wine_path wine_args exe_path exe_args\n"); - return 0; - } - - char* wine_path = argv[1]; - - pid_t pid = fork(); - if (pid == 0) { - char** wine_argv = (char**) malloc(sizeof(char*) * (argc - 1)); - wine_argv[0] = wine_path; - for (int i = 2; i < argc; i++) { - wine_argv[i - 1] = argv[i]; - } - wine_argv[argc - 1] = NULL; - execv(wine_path, wine_argv); - printf("Error launching wine process\n"); - exit(1); - } else if (pid < 0) { - printf("Error forking process\n"); - exit(1); - } - - sleep(30); - - off_t last_pos = 0; - off_t last_size = 0; - char* log_directory = "/home/container/SNM2020/Saved/Logs"; - print_latest_log(log_directory, &last_pos, &last_size); - - - while (1) { - sleep(1); - print_latest_log(log_directory, &last_pos, &last_size); - } - - kill(pid, SIGTERM); - - return 0; -} \ No newline at end of file