ENV Variables
This commit is contained in:
parent
44b2874780
commit
7195382b7a
1 changed files with 39 additions and 0 deletions
39
app/gopherbook/config.go
Normal file
39
app/gopherbook/config.go
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// initializePaths sets up the directory paths based on environment variables
|
||||||
|
// or falls back to defaults. This should be called before any path is used.
|
||||||
|
func init() {
|
||||||
|
// Library path - where comic files are stored
|
||||||
|
if envPath := os.Getenv("GOPHERBOOK_LIBRARY_PATH"); envPath != "" {
|
||||||
|
libraryPath = envPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache path - where cover thumbnails are cached
|
||||||
|
if envPath := os.Getenv("GOPHERBOOK_CACHE_PATH"); envPath != "" {
|
||||||
|
cachePath = envPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config/etc path - where user data and settings are stored
|
||||||
|
if envPath := os.Getenv("GOPHERBOOK_CONFIG_PATH"); envPath != "" {
|
||||||
|
etcPath = envPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch path - where files are auto-imported from
|
||||||
|
if envPath := os.Getenv("GOPHERBOOK_WATCH_PATH"); envPath != "" {
|
||||||
|
watchPath = envPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data root - if set, use this as base for all paths
|
||||||
|
// This is useful for XDG compliance or systemd DynamicUser
|
||||||
|
if dataRoot := os.Getenv("GOPHERBOOK_DATA_ROOT"); dataRoot != "" {
|
||||||
|
libraryPath = filepath.Join(dataRoot, "library")
|
||||||
|
cachePath = filepath.Join(dataRoot, "cache", "covers")
|
||||||
|
etcPath = filepath.Join(dataRoot, "etc")
|
||||||
|
watchPath = filepath.Join(dataRoot, "watch")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue