Added filesystem label detection, btrfs subvolumes should now be grouped under one partition and the filesystem type will now be shown if enabled in config.yaml
This commit is contained in:
parent
b8d7017299
commit
7c493dc9f9
@ -3,4 +3,5 @@ fetch_script: auto
|
|||||||
ansii_colors: []
|
ansii_colors: []
|
||||||
force_config_ansii: false
|
force_config_ansii: false
|
||||||
dependency_warning: true
|
dependency_warning: true
|
||||||
|
show_fs_type: true
|
||||||
hidden_gpus: []
|
hidden_gpus: []
|
||||||
|
@ -15,12 +15,21 @@ for i in $(seq ${MOUNTED_PARTITIONS}); do
|
|||||||
device="PARTITION${i}_DEVICE"
|
device="PARTITION${i}_DEVICE"
|
||||||
mountpoint="PARTITION${i}_MOUNTPOINT"
|
mountpoint="PARTITION${i}_MOUNTPOINT"
|
||||||
label="PARTITION${i}_LABEL"
|
label="PARTITION${i}_LABEL"
|
||||||
|
type="PARTITION${i}_TYPE"
|
||||||
total="PARTITION${i}_TOTAL_SIZE"
|
total="PARTITION${i}_TOTAL_SIZE"
|
||||||
used="PARTITION${i}_USED_SIZE"
|
used="PARTITION${i}_USED_SIZE"
|
||||||
if [ -z "${!label}" ]; then
|
if [ -z "${!type}" ]; then
|
||||||
echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}"
|
if [ -z "${!label}" ]; then
|
||||||
|
echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}"
|
||||||
|
else
|
||||||
|
echo -e "${C3}Partition ${!label}: ${C4}${!used}/${!total}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${C3}Partition ${!label}: ${C4}${!used}/${!total}"
|
if [ -z "${!label}" ]; then
|
||||||
|
echo -e "${C3}Partition ${!mountpoint} (${!type}): ${C4}${!used}/${!total}"
|
||||||
|
else
|
||||||
|
echo -e "${C3}Partition ${!label} (${!type}): ${C4}${!used}/${!total}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -z "$DISPLAY_PROTOCOL" ]; then
|
if [ ! -z "$DISPLAY_PROTOCOL" ]; then
|
||||||
|
5
main.go
5
main.go
@ -22,6 +22,7 @@ var config = StormfetchConfig{
|
|||||||
AnsiiColors: make([]int, 0),
|
AnsiiColors: make([]int, 0),
|
||||||
ForceConfigAnsii: false,
|
ForceConfigAnsii: false,
|
||||||
DependencyWarning: true,
|
DependencyWarning: true,
|
||||||
|
ShowFSType: false,
|
||||||
HiddenGPUS: make([]int, 0),
|
HiddenGPUS: make([]int, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ type StormfetchConfig struct {
|
|||||||
AnsiiColors []int `yaml:"ansii_colors"`
|
AnsiiColors []int `yaml:"ansii_colors"`
|
||||||
ForceConfigAnsii bool `yaml:"force_config_ansii"`
|
ForceConfigAnsii bool `yaml:"force_config_ansii"`
|
||||||
DependencyWarning bool `yaml:"dependency_warning"`
|
DependencyWarning bool `yaml:"dependency_warning"`
|
||||||
|
ShowFSType bool `yaml:"show_fs_type"`
|
||||||
HiddenGPUS []int `yaml:"hidden_gpus"`
|
HiddenGPUS []int `yaml:"hidden_gpus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +130,9 @@ func SetupFetchEnv() []string {
|
|||||||
if part.Label != "" {
|
if part.Label != "" {
|
||||||
env["PARTITION"+strconv.Itoa(i+1)+"_LABEL"] = part.Label
|
env["PARTITION"+strconv.Itoa(i+1)+"_LABEL"] = part.Label
|
||||||
}
|
}
|
||||||
|
if part.Type != "" && config.ShowFSType {
|
||||||
|
env["PARTITION"+strconv.Itoa(i+1)+"_TYPE"] = part.Type
|
||||||
|
}
|
||||||
env["PARTITION"+strconv.Itoa(i+1)+"_TOTAL_SIZE"] = FormatBytes(part.TotalSize)
|
env["PARTITION"+strconv.Itoa(i+1)+"_TOTAL_SIZE"] = FormatBytes(part.TotalSize)
|
||||||
env["PARTITION"+strconv.Itoa(i+1)+"_USED_SIZE"] = FormatBytes(part.UsedSize)
|
env["PARTITION"+strconv.Itoa(i+1)+"_USED_SIZE"] = FormatBytes(part.UsedSize)
|
||||||
env["PARTITION"+strconv.Itoa(i+1)+"_FREE_SIZE"] = FormatBytes(part.FreeSize)
|
env["PARTITION"+strconv.Itoa(i+1)+"_FREE_SIZE"] = FormatBytes(part.FreeSize)
|
||||||
|
22
utils.go
22
utils.go
@ -319,6 +319,7 @@ type partition struct {
|
|||||||
Device string
|
Device string
|
||||||
MountPoint string
|
MountPoint string
|
||||||
Label string
|
Label string
|
||||||
|
Type string
|
||||||
TotalSize uint64
|
TotalSize uint64
|
||||||
UsedSize uint64
|
UsedSize uint64
|
||||||
FreeSize uint64
|
FreeSize uint64
|
||||||
@ -328,6 +329,10 @@ func getMountedPartitions() []partition {
|
|||||||
mounts, err := mountinfo.GetMounts(func(info *mountinfo.Info) (skip, stop bool) {
|
mounts, err := mountinfo.GetMounts(func(info *mountinfo.Info) (skip, stop bool) {
|
||||||
return !strings.HasPrefix(info.Source, "/dev/"), false
|
return !strings.HasPrefix(info.Source, "/dev/"), false
|
||||||
})
|
})
|
||||||
|
fslabels, err := os.ReadDir("/dev/disk/by-label")
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
partlabels, err := os.ReadDir("/dev/disk/by-partlabel")
|
partlabels, err := os.ReadDir("/dev/disk/by-partlabel")
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
@ -340,16 +345,33 @@ func getMountedPartitions() []partition {
|
|||||||
}
|
}
|
||||||
labels[link] = entry.Name()
|
labels[link] = entry.Name()
|
||||||
}
|
}
|
||||||
|
for _, entry := range fslabels {
|
||||||
|
link, err := filepath.EvalSymlinks(filepath.Join("/dev/disk/by-label/", entry.Name()))
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
labels[link] = entry.Name()
|
||||||
|
}
|
||||||
var partitions []partition
|
var partitions []partition
|
||||||
for _, entry := range mounts {
|
for _, entry := range mounts {
|
||||||
p := partition{
|
p := partition{
|
||||||
entry.Source,
|
entry.Source,
|
||||||
entry.Mountpoint,
|
entry.Mountpoint,
|
||||||
"",
|
"",
|
||||||
|
entry.FSType,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
}
|
}
|
||||||
|
skip := false
|
||||||
|
for _, part := range partitions {
|
||||||
|
if part.Device == p.Device {
|
||||||
|
skip = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skip {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if value, ok := labels[entry.Source]; ok {
|
if value, ok := labels[entry.Source]; ok {
|
||||||
p.Label = value
|
p.Label = value
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user