-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
211 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gmotd.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ansible.python.interpreterPath": "/bin/python" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
package config | ||
|
||
type Config struct { | ||
Hostname Hostname | ||
Smart Smart | ||
} | ||
import ( | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func Load(cfg *Config) error { | ||
viper.SetConfigName("gmotd") | ||
viper.SetConfigType("yaml") | ||
viper.AddConfigPath("/etc/gmotd") | ||
viper.AddConfigPath("$HOME/.gmotd") | ||
viper.AddConfigPath(".") | ||
|
||
setDefaults() | ||
|
||
if err := viper.ReadInConfig(); err != nil { | ||
if _, ok := err.(viper.ConfigFileNotFoundError); ok { | ||
return nil | ||
} | ||
return err | ||
} | ||
|
||
if err := viper.Unmarshal(cfg); err != nil { | ||
return err | ||
} | ||
|
||
type Hostname struct { | ||
Disabled bool | ||
Color string | ||
Figlet bool | ||
FigletFont string | ||
FigletFontDir string | ||
return nil | ||
} | ||
|
||
type Smart struct { | ||
Disabled bool | ||
Disks []string | ||
func setDefaults() { | ||
viper.SetDefault("zpool.disabled", true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package config | ||
|
||
type Config struct { | ||
Hostname *Hostname `mapstructure:"hostname"` | ||
Uptime *Uptime `mapstructure:"uptime"` | ||
SysInfo *SysInfo `mapstructure:"sysinfo"` | ||
Zpool *Zpool `mapstructure:"zpool"` | ||
Docker *Docker `mapstructure:"docker"` | ||
Smart *Smart `mapstructure:"smart"` | ||
} | ||
|
||
type Hostname struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
Color string `mapstructure:"color"` | ||
Figlet bool `mapstructure:"figlet"` | ||
FigletFont string `mapstructure:"figlet_font"` | ||
FigletFontDir string `mapstructure:"figlet_font_dir"` | ||
} | ||
|
||
type Uptime struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
Precision int `mapstructure:"precision"` | ||
} | ||
|
||
type SysInfo struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
} | ||
|
||
type Zpool struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
} | ||
|
||
type Docker struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
IgnoreContainers []string `mapstructure:"ignore_containers"` | ||
} | ||
|
||
type Smart struct { | ||
Disabled bool `mapstructure:"disabled"` | ||
Disks []string `mapstructure:"disks"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.