mirror of
https://github.com/parkervcp/eggs.git
synced 2024-11-29 18:58:15 +08:00
Update: Swords 'n Magic and Stuff
This commit is contained in:
parent
9c08f3fd5e
commit
b8adc9556e
@ -4,16 +4,16 @@
|
|||||||
"version": "PTDL_v2",
|
"version": "PTDL_v2",
|
||||||
"update_url": null
|
"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",
|
"name": "Swords 'n Magic and Stuff",
|
||||||
"author": "josdekurk@gmail.com",
|
"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",
|
"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,
|
"features": null,
|
||||||
"docker_images": {
|
"docker_images": {
|
||||||
"ghcr.io\/parkervcp\/yolks:wine_staging": "ghcr.io\/parkervcp\/yolks:wine_staging"
|
"Wine": "ghcr.io\/parkervcp\/yolks:wine_latest"
|
||||||
},
|
},
|
||||||
"file_denylist": [],
|
"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": {
|
"config": {
|
||||||
"files": "{}",
|
"files": "{}",
|
||||||
"startup": "{\r\n \"done\": \"Succeeded to create Steam session with ID\"\r\n}",
|
"startup": "{\r\n \"done\": \"Succeeded to create Steam session with ID\"\r\n}",
|
||||||
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"installation": {
|
"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",
|
"container": "ghcr.io\/parkervcp\/installers:debian",
|
||||||
"entrypoint": "bash"
|
"entrypoint": "bash"
|
||||||
}
|
}
|
||||||
@ -157,16 +157,6 @@
|
|||||||
"user_editable": true,
|
"user_editable": true,
|
||||||
"rules": "required|string|max:20",
|
"rules": "required|string|max:20",
|
||||||
"field_type": "text"
|
"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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Binary file not shown.
@ -1,133 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user