From 667d766cd757fdbdffe80dcc74c8983dfa82f945 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Thu, 16 Nov 2023 22:07:58 -0800 Subject: [PATCH] chore: update readme and add RESTICUI_PORT env var --- README.md | 34 +++++++++++++++++++++++++++++++--- resticui.go | 9 +++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index eb24762a..7addaca2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,28 @@ Feature Support * [ ] Restore files from a snapshot (use restic UI to identify a snapshot to restore, use restic cli to restore it today) * [ ] Prune snapshots after backup operations (recommend periodically running `restic prune` on the CLI until this feature is supported) +# Getting Started + +## Running + +Installation options + + * Download a release from the [releases page](https://github.com/garethgeorge/resticui/releases), extract and run the binary (you may need to mark it executable e.g. `chmod +x resticui`). + * Build from source ([see below](#building)). + +ResticUI is accessible from a web browser. By default it binds to `0.0.0.0:9898` and can be accessed at `http://localhost:9898`. + +# Configuration + +**Environment Variables** + + * RESTICUI_PORT - the port to bind to. Defaults to 9898. + +**Configuration File** + +ResticUI uses a JSON config. The default config location is `$HOME/.config/resticui/config.json` or if `$XDG_CONFIG_HOME` is set, `$XDG_CONFIG_HOME/resticui/config.json`. + + ## Screenshots Configuring a backup plan: @@ -36,10 +58,16 @@ Running backup operation: Browsing snapshots: ![Browse Backup](./screenshots/screenshot-browse.png) -# Dependencies +# Developer Setup -## Dev +## Dev Depedencies +**Basic Dependencies** + + * Node.JS for UI development + * Go 1.21 or greater for server development + +**To Edit Protobuffers** ```sh apt install -y protobuf-compiler go install \ @@ -53,6 +81,6 @@ go install github.com/bufbuild/buf/cmd/buf@v1.27.2 ## Building ```sh -(cd webui && npm run build) +(cd webui && npm i && npm run build) (cd cmd/resticui && go build .) ``` diff --git a/resticui.go b/resticui.go index e374fa3d..3f93a801 100644 --- a/resticui.go +++ b/resticui.go @@ -3,6 +3,7 @@ package main import ( "context" "errors" + "fmt" "io/fs" "net/http" "os" @@ -24,11 +25,15 @@ import ( ) func main() { + port := os.Getenv("RESTICUI_PORT") + if port == "" { + port = "9898" + } + ctx := context.Background() ctx, cancel := context.WithCancel(ctx) go onterm(cancel) - if _, err := config.Default.Get(); err != nil { zap.S().Fatalf("Error loading config: %v", err) } @@ -81,7 +86,7 @@ func main() { // Serve the HTTP gateway server := &http.Server{ - Addr: ":9090", + Addr: fmt.Sprintf(":%s", port), Handler: mux, }