add filebrowser (#56)

This commit is contained in:
Muhammad Atif Ali
2023-09-27 17:16:03 +03:00
committed by GitHub
parent c3d8a9949c
commit 59243bdf23
5 changed files with 257 additions and 1 deletions

31
filebrowser/README.md Normal file
View File

@@ -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"
}
```

57
filebrowser/main.tf Normal file
View File

@@ -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"
}

21
filebrowser/run.sh Normal file
View File

@@ -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"