summaryrefslogtreecommitdiff
path: root/minecctl
diff options
context:
space:
mode:
Diffstat (limited to 'minecctl')
-rw-r--r--minecctl/misc-commands.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/minecctl/misc-commands.c b/minecctl/misc-commands.c
index 054279b..5a6fe3a 100644
--- a/minecctl/misc-commands.c
+++ b/minecctl/misc-commands.c
@@ -17,6 +17,14 @@
#include "shared/systemd.h"
#include "misc.h"
+#include "examples/eula.txt.h"
+#include "examples/example.mcserver.h"
+#include "examples/minecproxy.conf.h"
+#include "examples/minecproxy.service.h"
+#include "examples/minecserver@.service.h"
+#include "examples/README.TXT.h"
+#include "examples/server.properties.h"
+
static bool create_link(int dfd, const char *source, const char *target)
{
if (symlinkat(target, dfd, source) < 0) {
@@ -27,10 +35,10 @@ static bool create_link(int dfd, const char *source, const char *target)
return true;
}
-static bool write_cfg_file(int dfd, const char *name, const char *content)
+static bool write_cfg_file(int dfd, const char *name, unsigned char *content,
+ size_t len)
{
int fd;
- ssize_t len = strlen(content);
ssize_t done = 0, r;
bool rv = true;
@@ -57,14 +65,6 @@ static bool write_cfg_file(int dfd, const char *name, const char *content)
return rv;
}
-static const char txt_server_readme[] = "This is the server readme\n";
-static const char txt_server_eula[] = "This is the server eula\n";
-static const char txt_server_properties[] = "This is the server properties\n";
-static const char txt_server_conf[] = "This is the server conf\n";
-static const char txt_minecproxy_conf[] = "This is the minecproxy conf\n";
-static const char txt_minecproxy_service[] = "This is the minecproxy service\n";
-static const char txt_minecserver_service[] = "This is the minecserver service\n";
-
static bool find_user_service(int xfd, const char *service)
{
int dfd;
@@ -118,7 +118,7 @@ static bool find_user_service(int xfd, const char *service)
}
static bool create_user_service(int xfd, const char *service,
- const char *content)
+ unsigned char *content, size_t len)
{
int sfd, ufd = -1;
bool rv = false;
@@ -134,7 +134,7 @@ static bool create_user_service(int xfd, const char *service,
if (ufd < 0)
goto out;
- if (!write_cfg_file(ufd, service, content))
+ if (!write_cfg_file(ufd, service, content, len))
goto out;
info("Created user service file $XDG_CONFIG_HOME/systemd/user/%s",
@@ -162,17 +162,21 @@ static bool create_config_tree(int xfd)
if (sfd < 0)
goto out;
- if (!write_cfg_file(sfd, "README.TXT", txt_server_readme))
+ if (!write_cfg_file(sfd, "README.TXT", ___examples_README_TXT,
+ ___examples_README_TXT_len))
goto out;
- efd = open_subdir(sfd, "example-server", true);
+ efd = open_subdir(sfd, "example", true);
if (efd < 0)
goto out;
- if (!write_cfg_file(efd, "eula.txt", txt_server_eula))
+ if (!write_cfg_file(efd, "eula.txt", ___examples_eula_txt,
+ ___examples_eula_txt_len))
goto out;
- if (!write_cfg_file(efd, "server.properties", txt_server_properties))
+ if (!write_cfg_file(efd, "server.properties",
+ ___examples_server_properties,
+ ___examples_server_properties_len))
goto out;
if (!create_link(efd, "server.jar", "../server.jar"))
@@ -182,10 +186,13 @@ static bool create_config_tree(int xfd)
if (cfd < 0)
goto out;
- if (!write_cfg_file(cfd, "example-server.mcserver", txt_server_conf))
+ if (!write_cfg_file(cfd, "example.mcserver",
+ ___examples_example_mcserver,
+ ___examples_example_mcserver_len))
goto out;
- if (!write_cfg_file(cfd, "minecproxy.conf", txt_minecproxy_conf))
+ if (!write_cfg_file(cfd, "minecproxy.conf", ___examples_minecproxy_conf,
+ ___examples_minecproxy_conf_len))
goto out;
info("Created configuration in $XDG_CONFIG_HOME/minecproxy");
@@ -228,11 +235,13 @@ bool do_init(struct cfg *cfg)
}
if (!create_user_service(xfd, "minecserver@.service",
- txt_minecserver_service))
+ ___examples_minecserver__service,
+ ___examples_minecserver__service_len))
goto out;
if (!create_user_service(xfd, "minecproxy.service",
- txt_minecproxy_service))
+ ___examples_minecproxy_service,
+ ___examples_minecproxy_service_len))
goto out;
rv = true;
@@ -424,4 +433,3 @@ bool do_status(struct cfg *cfg)
return true;
}
-