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] 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@hRdw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;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