From b39fe7c4e88c35cdd150f9d260611e901213e804 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 20:27:54 +0000 Subject: [PATCH 01/16] add filebrowser db path var --- filebrowser/main.tf | 7 +++++++ filebrowser/run.sh | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index e624004..0fd336d 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -15,6 +15,12 @@ variable "agent_id" { description = "The ID of a Coder agent." } +variable "db_path" { + type = string + description = "The path to the filebrowser database." + default = "~/filebrowser.db" +} + variable "log_path" { type = string description = "The path to log filebrowser to." @@ -42,6 +48,7 @@ resource "coder_script" "filebrowser" { PORT : var.port, FOLDER : var.folder, LOG_PATH : var.log_path, + DB_PATH : var.db_path, }) run_on_start = true } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 91bf368..e846631 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -14,8 +14,8 @@ ROOT_DIR=$${ROOT_DIR/\~/$HOME} printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}' \n\n" +printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT} -d ${DB_PATH}' \n\n" -filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH} 2>&1 & +filebrowser --noauth --root $ROOT_DIR --port ${PORT} -d ${DB_PATH} >${LOG_PATH} 2>&1 & printf "📝 Logs at ${LOG_PATH} \n\n" From 412c35033e0cbdaa1c4e4f22f83987ee77d623d2 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:00:19 +0000 Subject: [PATCH 02/16] added db path optionality --- filebrowser/main.tf | 2 +- filebrowser/run.sh | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 0fd336d..c41192a 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -18,7 +18,7 @@ variable "agent_id" { variable "db_path" { type = string description = "The path to the filebrowser database." - default = "~/filebrowser.db" + default = null } variable "log_path" { diff --git a/filebrowser/run.sh b/filebrowser/run.sh index e846631..2f5377b 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -12,10 +12,20 @@ printf "👷 Starting filebrowser in background... \n\n" ROOT_DIR=${FOLDER} ROOT_DIR=$${ROOT_DIR/\~/$HOME} +DB_COMMAND="" + +if [ -z "${DB_PATH}" ]; then + echo "DB_PATH not set, skipping flag" +else + echo "DB_PATH is set!" + DB_COMMAND="-d ${DB_PATH}" + echo "Command: $${DB_COMMAND}" +fi + printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT} -d ${DB_PATH}' \n\n" +printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_COMMAND}' \n\n" -filebrowser --noauth --root $ROOT_DIR --port ${PORT} -d ${DB_PATH} >${LOG_PATH} 2>&1 & +filebrowser --noauth --root $ROOT_DIR --port ${PORT} ${DB_COMMAND} >${LOG_PATH} 2>&1 & printf "📝 Logs at ${LOG_PATH} \n\n" From 4fd37e0d67fced1119df528b7f58abafe0017e44 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:03:13 +0000 Subject: [PATCH 03/16] udpated var reference --- filebrowser/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 2f5377b..43863f7 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -26,6 +26,6 @@ printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_COMMAND}' \n\n" -filebrowser --noauth --root $ROOT_DIR --port ${PORT} ${DB_COMMAND} >${LOG_PATH} 2>&1 & +filebrowser --noauth --root $ROOT_DIR --port ${PORT} $${DB_COMMAND} >${LOG_PATH} 2>&1 & printf "📝 Logs at ${LOG_PATH} \n\n" From dad94ec735ac1eb33ec6384f5a9f1646d518a706 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:05:41 +0000 Subject: [PATCH 04/16] reverting to simpler implementation --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index c41192a..0fd336d 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -18,7 +18,7 @@ variable "agent_id" { variable "db_path" { type = string description = "The path to the filebrowser database." - default = null + default = "~/filebrowser.db" } variable "log_path" { From 04000b43caef82280208991df88a0200524f4390 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:15:10 +0000 Subject: [PATCH 05/16] removed logic to test params --- filebrowser/main.tf | 4 ++-- filebrowser/run.sh | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 0fd336d..3cc8183 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -18,7 +18,7 @@ variable "agent_id" { variable "db_path" { type = string description = "The path to the filebrowser database." - default = "~/filebrowser.db" + default = "" } variable "log_path" { @@ -48,7 +48,7 @@ resource "coder_script" "filebrowser" { PORT : var.port, FOLDER : var.folder, LOG_PATH : var.log_path, - DB_PATH : var.db_path, + DB_PATH : var.db_path }) run_on_start = true } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 43863f7..89043e2 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -12,20 +12,15 @@ printf "👷 Starting filebrowser in background... \n\n" ROOT_DIR=${FOLDER} ROOT_DIR=$${ROOT_DIR/\~/$HOME} -DB_COMMAND="" - if [ -z "${DB_PATH}" ]; then - echo "DB_PATH not set, skipping flag" -else - echo "DB_PATH is set!" - DB_COMMAND="-d ${DB_PATH}" - echo "Command: $${DB_COMMAND}" + echo "DB_PATH is empty" +# DB_PATH=$${ROOT_DIR}/filebrowser.db fi printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_COMMAND}' \n\n" +printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}' \n\n" # -d ${DB_PATH} -filebrowser --noauth --root $ROOT_DIR --port ${PORT} $${DB_COMMAND} >${LOG_PATH} 2>&1 & +filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} printf "📝 Logs at ${LOG_PATH} \n\n" From 5a8b8763cb488bf78bd455fd873762c222992440 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:19:02 +0000 Subject: [PATCH 06/16] corrected optional logic --- filebrowser/run.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 89043e2..71390da 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -12,15 +12,18 @@ printf "👷 Starting filebrowser in background... \n\n" ROOT_DIR=${FOLDER} ROOT_DIR=$${ROOT_DIR/\~/$HOME} +# Set the database flag if DB_PATH is set +DB_FLAG="" if [ -z "${DB_PATH}" ]; then echo "DB_PATH is empty" -# DB_PATH=$${ROOT_DIR}/filebrowser.db +else + DB_FLAG="-d ${DB_PATH}" fi printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}' \n\n" # -d ${DB_PATH} +printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" # -d ${DB_PATH} -filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} +filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH}$${DB_FLAG} 2>&1 & # -d ${DB_PATH} printf "📝 Logs at ${LOG_PATH} \n\n" From d6e7363e3907b5747dfc112f91267570e74242bd Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:28:51 +0000 Subject: [PATCH 07/16] added validation, fixed ref --- filebrowser/main.tf | 6 +++++- filebrowser/run.sh | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 3cc8183..37c7aac 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -18,7 +18,11 @@ variable "agent_id" { variable "db_path" { type = string description = "The path to the filebrowser database." - default = "" + default = "filebrowser.db" + validation { + condition = ends_with(var.database_path, "filebrowser.db") + error_message = "The database_path must end with 'filebrowser.db'." + } } variable "log_path" { diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 71390da..3735efa 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -14,9 +14,8 @@ ROOT_DIR=$${ROOT_DIR/\~/$HOME} # Set the database flag if DB_PATH is set DB_FLAG="" -if [ -z "${DB_PATH}" ]; then - echo "DB_PATH is empty" -else +if [ "${DB_PATH}" != "filebrowser.db" ]; then + echo ">>> flag set!" DB_FLAG="-d ${DB_PATH}" fi @@ -24,6 +23,6 @@ printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" # -d ${DB_PATH} -filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH}$${DB_FLAG} 2>&1 & # -d ${DB_PATH} +filebrowser --noauth --root $ROOT_DIR --port ${PORT}${DB_FLAG} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} printf "📝 Logs at ${LOG_PATH} \n\n" From 1b30a8e1de1956d7286e69c4340f98686b271b61 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:30:49 +0000 Subject: [PATCH 08/16] db_path -> database_path --- filebrowser/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 37c7aac..b730160 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -15,7 +15,7 @@ variable "agent_id" { description = "The ID of a Coder agent." } -variable "db_path" { +variable "database_path" { type = string description = "The path to the filebrowser database." default = "filebrowser.db" @@ -52,7 +52,7 @@ resource "coder_script" "filebrowser" { PORT : var.port, FOLDER : var.folder, LOG_PATH : var.log_path, - DB_PATH : var.db_path + DB_PATH : var.database_path }) run_on_start = true } From 226532a03c62df0e48be557208b877819ffba87d Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:31:53 +0000 Subject: [PATCH 09/16] endswith typo --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index b730160..572b416 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -20,7 +20,7 @@ variable "database_path" { description = "The path to the filebrowser database." default = "filebrowser.db" validation { - condition = ends_with(var.database_path, "filebrowser.db") + condition = endswith(var.database_path, "filebrowser.db") error_message = "The database_path must end with 'filebrowser.db'." } } From fe230ec764a40cd5bdf0892343b90b0cc79ed1c2 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:39:13 +0000 Subject: [PATCH 10/16] upgraded terraform verison --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 572b416..f0edd78 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.0" + required_version = ">= 1.3" required_providers { coder = { From 5146af839d99bc55075b3801003e23c7499f9e5d Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:45:09 +0000 Subject: [PATCH 11/16] updated readme, regex instead of endswith --- filebrowser/README.md | 10 ++++++++++ filebrowser/main.tf | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 9a08398..694541f 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -31,3 +31,13 @@ module "filebrowser" { folder = "/home/coder/project" } ``` + +### Specify location of `filebrowser.db` + +```hcl +module "filebrowser" { + source = "https://registry.coder.com/modules/filebrowser" + agent_id = coder_agent.example.id + database_path = ".config/filebrowser.db" +} +``` \ No newline at end of file diff --git a/filebrowser/main.tf b/filebrowser/main.tf index f0edd78..ef653bf 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.3" + required_version = ">= 1.0" required_providers { coder = { @@ -20,7 +20,7 @@ variable "database_path" { description = "The path to the filebrowser database." default = "filebrowser.db" validation { - condition = endswith(var.database_path, "filebrowser.db") + condition = can(regex(".*filebrowser\\.db$", var.database_path)) error_message = "The database_path must end with 'filebrowser.db'." } } From ba9cb6dbd359954e22223c18a99407c33ca54ae0 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 21:52:39 +0000 Subject: [PATCH 12/16] attempting ends with --- filebrowser/main.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index ef653bf..d118318 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.0" + required_version = ">= 1.3" required_providers { coder = { @@ -20,7 +20,8 @@ variable "database_path" { description = "The path to the filebrowser database." default = "filebrowser.db" validation { - condition = can(regex(".*filebrowser\\.db$", var.database_path)) + condition = endswith(var.database_path, "filebrowser.db") + # condition = can(regex(".*filebrowser\\.db$", var.database_path)) error_message = "The database_path must end with 'filebrowser.db'." } } From 290db2ea33401aa71d12ae97d5894cab17c759c0 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 22:24:13 +0000 Subject: [PATCH 13/16] empty test, revert to regex until upgrade --- filebrowser/main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index d118318..1eb4a90 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.3" + required_version = ">= 1.0" required_providers { coder = { @@ -20,8 +20,8 @@ variable "database_path" { description = "The path to the filebrowser database." default = "filebrowser.db" validation { - condition = endswith(var.database_path, "filebrowser.db") - # condition = can(regex(".*filebrowser\\.db$", var.database_path)) + # condition = endswith(var.database_path, "filebrowser.db") + condition = can(regex(".*filebrowser\\.db$", var.database_path)) error_message = "The database_path must end with 'filebrowser.db'." } } From e9bf7245bbae90020092d9ecb323b4ccb7a0788c Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 22:27:00 +0000 Subject: [PATCH 14/16] fixed sh ref --- filebrowser/main.test.ts | 14 ++++++++++++++ filebrowser/main.tf | 3 +-- filebrowser/run.sh | 4 +--- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 filebrowser/main.test.ts diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts new file mode 100644 index 0000000..9d6cd11 --- /dev/null +++ b/filebrowser/main.test.ts @@ -0,0 +1,14 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "../test"; + +describe("azure-region", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, {}); + +}); diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 1eb4a90..f479488 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -9,7 +9,6 @@ terraform { } } -# Add required variables for your modules and remove any unneeded variables variable "agent_id" { type = string description = "The ID of a Coder agent." @@ -20,7 +19,7 @@ variable "database_path" { description = "The path to the filebrowser database." default = "filebrowser.db" validation { - # condition = endswith(var.database_path, "filebrowser.db") + # Ensures path leads to */filebrowser.db condition = can(regex(".*filebrowser\\.db$", var.database_path)) error_message = "The database_path must end with 'filebrowser.db'." } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 3735efa..bb93300 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -12,10 +12,8 @@ printf "👷 Starting filebrowser in background... \n\n" ROOT_DIR=${FOLDER} ROOT_DIR=$${ROOT_DIR/\~/$HOME} -# Set the database flag if DB_PATH is set DB_FLAG="" if [ "${DB_PATH}" != "filebrowser.db" ]; then - echo ">>> flag set!" DB_FLAG="-d ${DB_PATH}" fi @@ -23,6 +21,6 @@ printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" # -d ${DB_PATH} -filebrowser --noauth --root $ROOT_DIR --port ${PORT}${DB_FLAG} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} +filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} printf "📝 Logs at ${LOG_PATH} \n\n" From 3128167b8ef8ba460a8e803a339135fdef1fd4a8 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 22:30:18 +0000 Subject: [PATCH 15/16] forgot a space --- filebrowser/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index bb93300..bf60c73 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -14,7 +14,7 @@ ROOT_DIR=$${ROOT_DIR/\~/$HOME} DB_FLAG="" if [ "${DB_PATH}" != "filebrowser.db" ]; then - DB_FLAG="-d ${DB_PATH}" + DB_FLAG=" -d ${DB_PATH}" fi printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" From aaf56fe3fddcb36229b140b0f619a363f354105b Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Thu, 5 Oct 2023 22:56:25 +0000 Subject: [PATCH 16/16] finished tests --- filebrowser/README.md | 2 +- filebrowser/main.test.ts | 81 +++++++++++++++++++++++++++++++++++++++- filebrowser/run.sh | 4 +- 3 files changed, 82 insertions(+), 5 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 694541f..134eb52 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -40,4 +40,4 @@ module "filebrowser" { agent_id = coder_agent.example.id database_path = ".config/filebrowser.db" } -``` \ No newline at end of file +``` diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts index 9d6cd11..7541e65 100644 --- a/filebrowser/main.test.ts +++ b/filebrowser/main.test.ts @@ -6,9 +6,86 @@ import { testRequiredVariables, } from "../test"; -describe("azure-region", async () => { +describe("filebrowser", async () => { await runTerraformInit(import.meta.dir); - testRequiredVariables(import.meta.dir, {}); + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); + it("fails with wrong database_path", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + database_path: "nofb", + }).catch((e) => { + if (!e.message.startsWith("\nError: Invalid value for variable")) { + throw e; + } + }); + }); + + it("runs with default", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(0); + expect(output.stdout).toEqual([ + "\u001b[0;1mInstalling filebrowser ", + "", + "🥳 Installation comlete! ", + "", + "👷 Starting filebrowser in background... ", + "", + "📂 Serving /root at http://localhost:13339 ", + "", + "Running 'filebrowser --noauth --root /root --port 13339' ", + "", + "📝 Logs at /tmp/filebrowser.log", + ]); + }); + + it("runs with database_path var", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + database_path: ".config/filebrowser.db", + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(0); + expect(output.stdout).toEqual([ + "\u001b[0;1mInstalling filebrowser ", + "", + "🥳 Installation comlete! ", + "", + "👷 Starting filebrowser in background... ", + "", + "📂 Serving /root at http://localhost:13339 ", + "", + "Running 'filebrowser --noauth --root /root --port 13339 -d .config/filebrowser.db' ", + "", + "📝 Logs at /tmp/filebrowser.log", + ]); + }); + + it("runs with folder var", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + folder: "/home/coder/project", + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(0); + expect(output.stdout).toEqual([ + "\u001B[0;1mInstalling filebrowser ", + "", + "🥳 Installation comlete! ", + "", + "👷 Starting filebrowser in background... ", + "", + "📂 Serving /home/coder/project at http://localhost:13339 ", + "", + "Running 'filebrowser --noauth --root /home/coder/project --port 13339' ", + "", + "📝 Logs at /tmp/filebrowser.log", + ]); + }); }); diff --git a/filebrowser/run.sh b/filebrowser/run.sh index bf60c73..ffbee0f 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -19,8 +19,8 @@ fi printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" -printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" # -d ${DB_PATH} +printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" -filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} >${LOG_PATH} 2>&1 & # -d ${DB_PATH} +filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} >${LOG_PATH} 2>&1 & printf "📝 Logs at ${LOG_PATH} \n\n"