Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

add filebrowser #56

Merged
merged 13 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions .icons/filebrowser.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions filebrowser/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 57 additions & 0 deletions filebrowser/main.tf
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions filebrowser/run.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion new.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down