commit fd0856580fb9fd6a6a0385d1fe0fb86d3046eadb Author: nc5432 Date: Wed May 28 19:48:23 2025 -0400 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87bef35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +*.code-workspace \ No newline at end of file diff --git a/.secrets b/.secrets new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..d62e61f --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Server Controller +This project will primarily be a web API for my main website, allowing it to preview the resource utilization of my server, but it will also function as an admin console for me to manage my self-hosted services from. All services will be able to be launched, shutdown, and monitored through it. \ No newline at end of file diff --git a/ServerController.c b/ServerController.c new file mode 100644 index 0000000..8fb808b --- /dev/null +++ b/ServerController.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CONFIG "config.cfg" +#define SECRETS ".secrets" + +const int PORT; + +void sigintHandler(int signal){ + printf("Handled sigint\n"); + exit(0); +} + +void error(char *msg){ + write(0, msg, strlen(msg)); + exit(1); +} + +void readConfig(){ + FILE *file = fopen("config.cfg", "r"); + char buf[1024]; + while (fgets(buf, 1024, file) != NULL){ + printf("Line: \n%s\n", buf); + char *newbuf = calloc(1024, 1); + for (int i = 0; i < 1024; i++){ + if (buf[i] == '#') break; + else newbuf[i] = buf[i]; + } + printf("Newbuf: %s\n", newbuf); + char buf1[512]; + char buf2[512]; + if (sscanf(newbuf, "%s %s", buf1, buf2) == 2){ + printf("Values: %s %s\n", buf1, buf2); + } + free(newbuf); + } +} + +int main(){ + signal(SIGINT, sigintHandler); + readConfig(); + + return 0; +} diff --git a/config.cfg b/config.cfg new file mode 100644 index 0000000..e46ef44 --- /dev/null +++ b/config.cfg @@ -0,0 +1,3 @@ +port 8888 +# Minecraft is a cool game yep +program minecraft # still cool \ No newline at end of file diff --git a/controller b/controller new file mode 100755 index 0000000..bc49771 Binary files /dev/null and b/controller differ diff --git a/makefile b/makefile new file mode 100644 index 0000000..a3fbddb --- /dev/null +++ b/makefile @@ -0,0 +1,5 @@ +controller: + gcc -Wall ServerController.c -o controller -lmicrohttpd -lyaml + +clean: + rm controller \ No newline at end of file