diff --git a/nest-bot/src/os/os_functions.ts b/nest-bot/src/os/os_functions.ts index c06f25e..af2df2d 100644 --- a/nest-bot/src/os/os_functions.ts +++ b/nest-bot/src/os/os_functions.ts @@ -1,14 +1,8 @@ import { readFile, writeFile } from "fs/promises"; -import { exec, ExecException } from "child_process"; +import { exec, ExecException, execSync } from "child_process"; export async function add_root_caddyfile_config(username: string) { - const templateConfig = ( - await readFile("./src/os/templates/root_caddyfile_config.txt") - ).toString("utf8"); - - const newConfig = templateConfig.replace(//g, username); - - await writeFile("/etc/caddy/Caddyfile", newConfig, { flag: "a" }); + execSync(`nest caddy add ${username}.hackclub.app --user ${username}`) } function log_output(err: ExecException | null, stdout: string, stderr: string) { diff --git a/nest-bot/src/os/scripts/setup.sh b/nest-bot/src/os/scripts/setup.sh index 20a56e2..8df73a9 100755 --- a/nest-bot/src/os/scripts/setup.sh +++ b/nest-bot/src/os/scripts/setup.sh @@ -12,7 +12,6 @@ touch /var/lib/systemd/linger/$1 export XDG_RUNTIME_DIR=/run/user/$(id -u $1) systemctl --user -M $1@ daemon-reload systemctl --user -M $1@ enable caddy -systemctl reload caddy # Limits setquota -u $1 15G 15G 0 0 / diff --git a/nest-bot/src/os/templates/root_caddyfile_config.txt b/nest-bot/src/os/templates/root_caddyfile_config.txt deleted file mode 100644 index ffe2af1..0000000 --- a/nest-bot/src/os/templates/root_caddyfile_config.txt +++ /dev/null @@ -1,21 +0,0 @@ -.hackclub.app { - reverse_proxy unix//home//.webserver.sock { - health_status 2xx - health_interval 5s - health_timeout 60s - } - handle_errors { - @502 expression {err.status_code} == 502 - handle @502 { - respond * 502 { - body "This site is either down or does not exist. -If this site really does exist, please make sure your Caddy is running. Try systemctl --user start caddy. It is also possible you have a config issue, if so, please reach out to us on the slack #nest. -" - } - } - respond "{err.status_code} | {err.status_text} (on {re.host.1})" { - close - } - } -} - diff --git a/nest-bot/src/os/templates/user_caddyfile_config.txt b/nest-bot/src/os/templates/user_caddyfile_config.txt index 7363ecf..f03c958 100644 --- a/nest-bot/src/os/templates/user_caddyfile_config.txt +++ b/nest-bot/src/os/templates/user_caddyfile_config.txt @@ -2,7 +2,7 @@ admin unix//home//caddy-admin.sock } http://.hackclub.app { - bind unix/.webserver.sock|777 + bind unix/..hackclub.app.webserver.sock|777 root * /home//pub file_server { hide .git .env