Skip to content
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ SlurmCommander does not require any special privileges to be installed, see inst
### Site administrators

Instructions are same as for the regular users, with one minor perk.
Place the [config file](./cmd/scom/scom.conf) in `/etc/scom/scom.conf` to be used as global configuration source for all scom instances on that machine.
Place the [config file](./cmd/scom/scom.conf) in one of the following locations to be used as global configuration source for all scom instances on that machine.

1. /etc/scom/scom.conf
2. Any location, providing users with the environment variable `SCOM_CONF` containing path to config. file
3. Users $XDG_CONFIG_HOME/scom/scom.conf


__NOTE__: Users can still override global configuration options by changing config stanzas in their local `$HOME/scom/scom.conf`

Expand Down
16 changes: 16 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ func (cc *ConfigContainer) GetConfig() error {
cfgPaths = []string{defaults.SiteConfFile, home + "/" + defaults.AppName + "/" + defaults.ConfFileName}
}

// SCOM_CONF content, if exists
if scomConf, exists := os.LookupEnv(defaults.EnvConfVarName); exists && scomConf != "" {
// SCOM_CONF set
cfgPaths = append(cfgPaths, scomConf)
}

// $XDG_CONFIG_HOME/scom/scom.conf
if xdgConfHome, exists := os.LookupEnv("XDG_CONFIG_HOME"); exists && xdgConfHome != "" {
// XDG_CONFIG_HOME set
cfgPaths = append(cfgPaths, xdgConfHome+"/"+defaults.AppName+"/"+defaults.ConfFileName)
} else {
// XDG_CONFIG_HOME unset or empty
// If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
cfgPaths = append(cfgPaths, home+"/.config/"+defaults.AppName+"/"+defaults.ConfFileName)
}

for _, v := range cfgPaths {
log.Printf("Trying conf file: %s\n", v)
f, err := os.ReadFile(v)
Expand Down
7 changes: 4 additions & 3 deletions internal/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const (

AppName = "scom"

ConfFileName = "scom.conf"
SiteConfDir = "/etc/" + AppName + "/"
SiteConfFile = SiteConfDir + ConfFileName
EnvConfVarName = "SCOM_CONF"
ConfFileName = "scom.conf"
SiteConfDir = "/etc/" + AppName + "/"
SiteConfFile = SiteConfDir + ConfFileName

TemplatesDir = SiteConfDir + "templates"
TemplatesSuffix = ".sbatch"
Expand Down
5 changes: 3 additions & 2 deletions internal/model/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"strings"

"github.com/charmbracelet/lipgloss"
"github.com/CLIP-HPC/SlurmCommander/internal/keybindings"
"github.com/CLIP-HPC/SlurmCommander/internal/styles"
"github.com/CLIP-HPC/SlurmCommander/internal/version"
"github.com/charmbracelet/lipgloss"
)

// genTabs() generates top tabs
Expand Down Expand Up @@ -50,7 +50,8 @@ Petar Jager
CLIP-HPC @VBC

Contributors:
Seren,Ümit @VBC
Seren Ümit
Kilian Cavalotti
`

return s
Expand Down