diff --git a/.icons/filebrowser.svg b/.icons/filebrowser.svg new file mode 100644 index 0000000..5e78ecc --- /dev/null +++ b/.icons/filebrowser.svg @@ -0,0 +1,147 @@ + +image/svg+xml + + + + + \ No newline at end of file diff --git a/filebrowser/README.md b/filebrowser/README.md new file mode 100644 index 0000000..bd1ba07 --- /dev/null +++ b/filebrowser/README.md @@ -0,0 +1,31 @@ +--- +display_name: File Browser +description: A file browser for your workspace +icon: ../.icons/filebrowser.svg +maintainer_github: coder +verified: true +tags: [helper, filebrowser] +--- + +# File Browser + +A file browser for your workspace. + +```hcl +module "filebrowser" { + source = "https://registry.coder.com/modules/filebrowser" + agent_id = coder_agent.example.id +} +``` + +## Examples + +### Serve a specific directory + +```hcl +module "filebrowser" { + source = "https://registry.coder.com/modules/filebrowser" + agent_id = coder_agent.example.id + folder = "/home/coder/project" +} +``` diff --git a/filebrowser/main.tf b/filebrowser/main.tf new file mode 100644 index 0000000..e624004 --- /dev/null +++ b/filebrowser/main.tf @@ -0,0 +1,57 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 0.12" + } + } +} + +# Add required variables for your modules and remove any unneeded variables +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "log_path" { + type = string + description = "The path to log filebrowser to." + default = "/tmp/filebrowser.log" +} + +variable "port" { + type = number + description = "The port to run filebrowser on." + default = 13339 +} + +variable "folder" { + type = string + description = "--root value for filebrowser." + default = "~" +} + +resource "coder_script" "filebrowser" { + agent_id = var.agent_id + display_name = "File Browser" + icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" + script = templatefile("${path.module}/run.sh", { + LOG_PATH : var.log_path, + PORT : var.port, + FOLDER : var.folder, + LOG_PATH : var.log_path, + }) + run_on_start = true +} + +resource "coder_app" "filebrowser" { + agent_id = var.agent_id + slug = "filebrowser" + display_name = "File Browser" + url = "http://localhost:${var.port}" + icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" + subdomain = true + share = "owner" +} diff --git a/filebrowser/run.sh b/filebrowser/run.sh new file mode 100644 index 0000000..427c864 --- /dev/null +++ b/filebrowser/run.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +BOLD='\033[0;1m' +echo "$${BOLD}Installing filebrowser \n\n" + +curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash + +echo "🥳 Installation comlete! \n\n" + +echo "👷 Starting filebrowser in background... \n\n" + +ROOT_DIR=${FOLDER} +ROOT_DIR=$${ROOT_DIR/\~/$HOME} + +echo "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" + +echo "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}' \n\n" + +filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH} 2>&1 & + +echo "📝 Logs at ${LOG_PATH} \n\n" diff --git a/new.sh b/new.sh index ea80ffe..29e4f52 100755 --- a/new.sh +++ b/new.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # This scripts creates a new sample moduledir with requried files # Run it like : ./new.sh my-module