From a67b48232166af9b6f1b83d22f941bd9ae3e1223 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Mon, 28 Oct 2024 17:30:14 +0800 Subject: [PATCH 1/5] add check if filebrowser is installes --- filebrowser/run.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 8a31d4db..22535a8f 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -1,11 +1,21 @@ #!/usr/bin/env bash BOLD='\033[0;1m' -printf "$${BOLD}Installing filebrowser \n\n" -curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash - -printf "🥳 Installation complete! \n\n" +# Check if filebrowser is installed +if command -v filebrowser &> /dev/null; then + printf "🥳 Filebrowser is already installed. Skipping installation.\n\n$" +else + printf "${BOLD}Installing Filebrowser...\n\n" + + # Install Filebrowser + if curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash; then + printf "🥳 Installation complete! Filebrowser is now installed.\n\n" + else + printf "❌ Installation failed! Please check the logs.\n\n" + exit 1 + fi +fi printf "👷 Starting filebrowser in background... \n\n" From 98e802801283e9aa9fbac5597db2748875206a6c Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Mon, 28 Oct 2024 23:45:47 +0800 Subject: [PATCH 2/5] double $$ --- filebrowser/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 22535a8f..5e706423 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -6,7 +6,7 @@ BOLD='\033[0;1m' if command -v filebrowser &> /dev/null; then printf "🥳 Filebrowser is already installed. Skipping installation.\n\n$" else - printf "${BOLD}Installing Filebrowser...\n\n" + printf "$${BOLD}Installing Filebrowser...\n\n" # Install Filebrowser if curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash; then From 32588f22fa9e0be810f4b54bb00dacb02595c162 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Tue, 29 Oct 2024 00:02:58 +0800 Subject: [PATCH 3/5] run './update-version.sh' --- filebrowser/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 1b53ffaa..0882d9e5 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -14,7 +14,7 @@ A file browser for your workspace. ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.22" + version = "1.0.23" agent_id = coder_agent.example.id } ``` @@ -28,7 +28,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.22" + version = "1.0.23" agent_id = coder_agent.example.id folder = "/home/coder/project" } @@ -39,7 +39,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.22" + version = "1.0.23" agent_id = coder_agent.example.id database_path = ".config/filebrowser.db" } From a2e39dc7387839994f57f502511aad1fd67ca530 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Wed, 30 Oct 2024 14:26:54 +0800 Subject: [PATCH 4/5] Align script with test script(test.ts) --- filebrowser/run.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 5e706423..6931f05e 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -2,21 +2,15 @@ BOLD='\033[0;1m' +printf "$${BOLD}Installing filebrowser \n\n" + # Check if filebrowser is installed -if command -v filebrowser &> /dev/null; then - printf "🥳 Filebrowser is already installed. Skipping installation.\n\n$" -else - printf "$${BOLD}Installing Filebrowser...\n\n" - - # Install Filebrowser - if curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash; then - printf "🥳 Installation complete! Filebrowser is now installed.\n\n" - else - printf "❌ Installation failed! Please check the logs.\n\n" - exit 1 - fi +if ! command -v filebrowser &> /dev/null; then + curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash fi +printf "🥳 Installation complete! \n\n" + printf "👷 Starting filebrowser in background... \n\n" ROOT_DIR=${FOLDER} From 5733928b7884980603986ddd68703b5584ac1075 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Wed, 30 Oct 2024 16:02:23 +0800 Subject: [PATCH 5/5] copy from https://github.com/coder/modules/blob/atif/qol-improvments/filebrowser/main.tf --- filebrowser/main.tf | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 4fd74598..ba83844b 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -20,13 +20,8 @@ data "coder_workspace_owner" "me" {} variable "agent_name" { type = string - description = "The name of the main deployment. (Used to build the subpath for coder_app.)" - default = "" - validation { - # If subdomain is false, then agent_name must be set. - condition = var.subdomain || var.agent_name != "" - error_message = "The agent_name must be set." - } + description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)" + default = null } variable "database_path" { @@ -73,6 +68,12 @@ variable "order" { default = null } +variable "slug" { + type = string + description = "The slug of the coder_app resource." + default = "filebrowser" +} + variable "subdomain" { type = bool description = <<-EOT @@ -85,7 +86,7 @@ variable "subdomain" { resource "coder_script" "filebrowser" { agent_id = var.agent_id display_name = "File Browser" - icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" + icon = "/icon/filebrowser.svg" script = templatefile("${path.module}/run.sh", { LOG_PATH : var.log_path, PORT : var.port, @@ -93,18 +94,30 @@ resource "coder_script" "filebrowser" { LOG_PATH : var.log_path, DB_PATH : var.database_path, SUBDOMAIN : var.subdomain, - SERVER_BASE_PATH : var.subdomain ? "" : format("/@%s/%s.%s/apps/filebrowser", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name), + SERVER_BASE_PATH : local.server_base_path }) run_on_start = true } resource "coder_app" "filebrowser" { agent_id = var.agent_id - slug = "filebrowser" + slug = var.slug display_name = "File Browser" - url = "http://localhost:${var.port}" - icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" + url = local.url + icon = "/icon/filebrowser.svg" subdomain = var.subdomain share = var.share order = var.order + + healthcheck { + url = local.healthcheck_url + interval = 5 + threshold = 6 + } } + +locals { + server_base_path = var.subdomain ? "" : format("/@%s/%s%s/apps/%s", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name != null ? ".${var.agent_name}" : "", var.slug) + url = "http://localhost:${var.port}${local.server_base_path}" + healthcheck_url = "http://localhost:${var.port}${local.server_base_path}/health" +} \ No newline at end of file