mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fd198d83e | ||
|
|
673f231c42 | ||
|
|
e311649a48 | ||
|
|
712fd78e21 | ||
|
|
7d83b0996d | ||
|
|
f3a016b674 | ||
|
|
0e2631d5b0 | ||
|
|
153758b68e | ||
|
|
ed45b739a5 | ||
|
|
8c380dbec4 | ||
|
|
7c493dc9f9 | ||
|
|
b8d7017299 |
@@ -8,12 +8,12 @@ ifeq ($(SYSCONFDIR),)
|
||||
SYSCONFDIR := $(PREFIX)/etc
|
||||
endif
|
||||
ifeq ($(GO),)
|
||||
GO := /usr/bin/go
|
||||
GO := $(shell type -a -P go | head -n 1)
|
||||
endif
|
||||
|
||||
build:
|
||||
mkdir -p build
|
||||
$(GO) build -ldflags "-w" -o build/stormfetch stormfetch
|
||||
$(GO) build -ldflags "-w -X 'main.systemConfigDir=$(SYSCONFDIR)'" -o build/stormfetch stormfetch
|
||||
|
||||
install: build/stormfetch config/
|
||||
mkdir -p $(DESTDIR)$(BINDIR)
|
||||
|
||||
@@ -20,7 +20,7 @@ Stormfetch is still in beta, so distro compatibility is limited. If you would li
|
||||
- Download `make` from your package manager
|
||||
- Run the following command to compile the project
|
||||
```
|
||||
make
|
||||
make SYSCONFDIR=/etc
|
||||
```
|
||||
- Run the following command to install stormfetch into your system. You may also append a DESTDIR variable at the end of this line if you wish to install in a different location
|
||||
```
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#/45;27;45;7
|
||||
${C1} 'o'
|
||||
'ooo'
|
||||
'ooxoo'
|
||||
'ooxxxoo'
|
||||
'oookkxxoo'
|
||||
'oiioxkkxxoo'
|
||||
':;:iiiioxxxoo'
|
||||
`'.;::ioxxoo'
|
||||
'-. `':;jiooo'
|
||||
'oooio-.. `'i:io'
|
||||
'ooooxxxxoio:,. `'-;'
|
||||
'ooooxxxxxkkxoooIi:-. `'
|
||||
'ooooxxxxxkkkkxoiiiiiji'
|
||||
'ooooxxxxxkxxoiiii:'` .i'
|
||||
'ooooxxxxxoi:::'` .;ioxo'
|
||||
'ooooxooi::'` .:iiixkxxo'
|
||||
'ooooi:'` `'';ioxxo'
|
||||
'i:'` '':io'
|
||||
'` `'
|
||||
@@ -0,0 +1,21 @@
|
||||
#/33;7;11;15
|
||||
${C1} /////////////
|
||||
/////////////////////
|
||||
///////${C2}*767${C1}////////////////
|
||||
//////${C2}7676767676*${C1}//////////////
|
||||
/////${C2}76767${C1}//${C2}7676767${C1}//////////////
|
||||
/////${C2}767676${C1}///${C2}*76767${C1}///////////////
|
||||
///////${C2}767676${C1}///${C2}76767${C1}.///${C2}7676*${C1}///////
|
||||
/////////${C2}767676${C1}//${C2}76767${C1}///${C2}767676${C1}////////
|
||||
//////////${C2}76767676767${C1}////${C2}76767${C1}/////////
|
||||
///////////${C2}76767676${C1}//////${C2}7676${C1}//////////
|
||||
////////////,${C2}7676${C1},///////${C2}767${C1}///////////
|
||||
/////////////*${C2}7676${C1}///////${C2}76${C1}////////////
|
||||
///////////////${C2}7676${C1}////////////////////
|
||||
///////////////${C2}7676${C1}///${C2}767${C1}////////////
|
||||
//////////////////////${C2}'${C1}////////////
|
||||
//////${C2}.7676767676767676767,${C1}//////
|
||||
/////${C2}767676767676767676767${C1}/////
|
||||
///////////////////////////
|
||||
/////////////////////
|
||||
/////////////
|
||||
+15
-18
@@ -1,18 +1,15 @@
|
||||
#/6;10;5;12
|
||||
${C1} @@@@@@@@@
|
||||
@@@~~~~~~~~~@@
|
||||
@@~~~ ~~@
|
||||
@~~ @
|
||||
@~ @@@ @
|
||||
@@~ @ @@
|
||||
@@~~ @
|
||||
@@@~~ ~@@ @@@
|
||||
~~~ ~~@@@ @@@@~~~
|
||||
~~~@@@@~~~~
|
||||
@@@@ @@@@@@@ ~~~~ @@@@
|
||||
~~~~@@@@ @@~~~~~~~@@ @@@@
|
||||
~~~~@@@@~~ ~~@@@@~~~~
|
||||
@@@ ~~~~ @@@@@ ~~~~ @@@
|
||||
~~~@@@@ @@@@~~~~~@@@@ @@@@~~~
|
||||
~~~~@@@~~~~ ~~~~@@@~~~
|
||||
~~~ ~~~
|
||||
#/27;39;5;12
|
||||
${C1}@@@@ ${C1}@@@${C2}*
|
||||
${C1}@@${C2}~~~~${C1}@@ ${C1}@@${C2}~~~
|
||||
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||
${C2}*${C1}@@${C2}~~ ${C1}@@@@ ${C2}~${C1}@@@@${C2}~~~ ${C1}@@@${C2}*
|
||||
${C2}~~ ${C1}@@${C2}~~~~${C1}@@ ${C2}~~~~ ${C1}@@${C2}~~~
|
||||
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||
${C2}*${C1}@@${C2}~~ ${C1}@@@@ ${C2}~${C1}@@@@${C2}~~~ ${C1}@@@${C2}*
|
||||
${C2}~~ ${C1}@@${C2}~~~~${C1}@@ ${C2}~~~~ ${C1}@@${C2}~~~
|
||||
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||
${C2}*${C1}@@${C2}~~ ${C2}~${C1}@@@@${C2}~~~
|
||||
${C2}~~ ${C2}~~~~
|
||||
|
||||
@@ -3,4 +3,5 @@ fetch_script: auto
|
||||
ansii_colors: []
|
||||
force_config_ansii: false
|
||||
dependency_warning: true
|
||||
show_fs_type: true
|
||||
hidden_gpus: []
|
||||
|
||||
+14
-3
@@ -5,6 +5,8 @@ echo -e "${C3}Hostname: ${C4}$(cat /etc/hostname)"
|
||||
echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)"
|
||||
echo -e "${C3}Packages: ${C4}$(get_packages)"
|
||||
echo -e "${C3}Shell: ${C4}${USER_SHELL}"
|
||||
echo -e "${C3}Init: ${C4}${INIT_SYSTEM}"
|
||||
echo -e "${C3}Libc: ${C4}${LIBC}"
|
||||
if [ ! -z "$CPU_MODEL" ]; then echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"; fi
|
||||
for i in $(seq ${CONNECTED_GPUS}); do
|
||||
gpu="GPU$i"
|
||||
@@ -15,12 +17,21 @@ for i in $(seq ${MOUNTED_PARTITIONS}); do
|
||||
device="PARTITION${i}_DEVICE"
|
||||
mountpoint="PARTITION${i}_MOUNTPOINT"
|
||||
label="PARTITION${i}_LABEL"
|
||||
type="PARTITION${i}_TYPE"
|
||||
total="PARTITION${i}_TOTAL_SIZE"
|
||||
used="PARTITION${i}_USED_SIZE"
|
||||
if [ -z "${!label}" ]; then
|
||||
echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}"
|
||||
if [ -z "${!type}" ]; then
|
||||
if [ -z "${!label}" ]; then
|
||||
echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}"
|
||||
else
|
||||
echo -e "${C3}Partition ${!label}: ${C4}${!used}/${!total}"
|
||||
fi
|
||||
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
|
||||
done
|
||||
if [ ! -z "$DISPLAY_PROTOCOL" ]; then
|
||||
|
||||
@@ -20,11 +20,11 @@ get_packages() {
|
||||
if command_exists rpm; then
|
||||
ARRAY+=("$(rpm -qa | wc -l) (rpm)")
|
||||
fi
|
||||
if command_exists pacman; then
|
||||
if command_exists xbps-query; then
|
||||
ARRAY+=("$(xbps-query -l | wc -l) (xbps)")
|
||||
fi
|
||||
if command_exists bpm; then
|
||||
ARRAY+=("$(bpm list -n) (bpm)")
|
||||
ARRAY+=("$(bpm list -c) (bpm)")
|
||||
fi
|
||||
if command_exists emerge; then
|
||||
ARRAY+=("$(ls -l /var/db/pkg/* | wc -l) (emerge)")
|
||||
|
||||
@@ -11,17 +11,23 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var systemConfigDir = "/etc/"
|
||||
|
||||
var configPath = ""
|
||||
var fetchScriptPath = ""
|
||||
|
||||
var TimeTaken = false
|
||||
|
||||
var config = StormfetchConfig{
|
||||
Ascii: "auto",
|
||||
FetchScript: "auto",
|
||||
AnsiiColors: make([]int, 0),
|
||||
ForceConfigAnsii: false,
|
||||
DependencyWarning: true,
|
||||
ShowFSType: false,
|
||||
HiddenGPUS: make([]int, 0),
|
||||
}
|
||||
|
||||
@@ -32,6 +38,7 @@ type StormfetchConfig struct {
|
||||
AnsiiColors []int `yaml:"ansii_colors"`
|
||||
ForceConfigAnsii bool `yaml:"force_config_ansii"`
|
||||
DependencyWarning bool `yaml:"dependency_warning"`
|
||||
ShowFSType bool `yaml:"show_fs_type"`
|
||||
HiddenGPUS []int `yaml:"hidden_gpus"`
|
||||
}
|
||||
|
||||
@@ -44,12 +51,12 @@ func main() {
|
||||
|
||||
func readConfig() {
|
||||
// Get home directory
|
||||
configDir, _ := os.UserConfigDir()
|
||||
userConfigDir, _ := os.UserConfigDir()
|
||||
// Find valid config directory
|
||||
if _, err := os.Stat(path.Join(configDir, "stormfetch/config.yaml")); err == nil {
|
||||
configPath = path.Join(configDir, "stormfetch/config.yaml")
|
||||
} else if _, err := os.Stat("/etc/stormfetch/config.yaml"); err == nil {
|
||||
configPath = "/etc/stormfetch/config.yaml"
|
||||
if _, err := os.Stat(path.Join(userConfigDir, "stormfetch/config.yaml")); err == nil {
|
||||
configPath = path.Join(userConfigDir, "stormfetch/config.yaml")
|
||||
} else if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/config.yaml")); err == nil {
|
||||
configPath = path.Join(systemConfigDir, "stormfetch/config.yaml")
|
||||
} else {
|
||||
log.Fatalf("Config file not found: %s", err.Error())
|
||||
}
|
||||
@@ -72,18 +79,19 @@ func readConfig() {
|
||||
log.Fatalf("Fetch script path points to a directory")
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(path.Join(configDir, "stormfetch/fetch_script.sh")); err == nil {
|
||||
fetchScriptPath = path.Join(configDir, "stormfetch/fetch_script.sh")
|
||||
} else if _, err := os.Stat("/etc/stormfetch/fetch_script.sh"); err == nil {
|
||||
fetchScriptPath = "/etc/stormfetch/fetch_script.sh"
|
||||
if _, err := os.Stat(path.Join(userConfigDir, "stormfetch/fetch_script.sh")); err == nil {
|
||||
fetchScriptPath = path.Join(userConfigDir, "stormfetch/fetch_script.sh")
|
||||
} else if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/fetch_script.sh")); err == nil {
|
||||
fetchScriptPath = path.Join(systemConfigDir, "stormfetch/fetch_script.sh")
|
||||
} else {
|
||||
log.Fatalf("Fetch script file not found: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func readFlags() {
|
||||
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "help message for flagname")
|
||||
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "help message for flagname")
|
||||
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "Set distro ascii")
|
||||
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "Set distro name")
|
||||
flag.BoolVar(&TimeTaken, "time-taken", false, "Show time taken for fetched information")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
@@ -107,19 +115,37 @@ func checkDependencies() {
|
||||
}
|
||||
}
|
||||
|
||||
func SetupFetchEnv() []string {
|
||||
func SetupFetchEnv(showTimeTaken bool) []string {
|
||||
var env = make(map[string]string)
|
||||
env["DISTRO_LONG_NAME"] = getDistroInfo().LongName
|
||||
env["DISTRO_SHORT_NAME"] = getDistroInfo().ShortName
|
||||
env["CPU_MODEL"] = getCPUName()
|
||||
env["CPU_THREADS"] = strconv.Itoa(getCPUThreads())
|
||||
setVariable := func(key string, setter func() string) {
|
||||
start := time.Now().UnixMilli()
|
||||
env[key] = setter()
|
||||
end := time.Now().UnixMilli()
|
||||
if showTimeTaken {
|
||||
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", key, end-start))
|
||||
}
|
||||
}
|
||||
setVariable("DISTRO_LONG_NAME", func() string { return getDistroInfo().LongName })
|
||||
setVariable("DISTRO_SHORT_NAME", func() string { return getDistroInfo().ShortName })
|
||||
setVariable("CPU_MODEL", func() string { return getCPUName() })
|
||||
setVariable("CPU_THREADS", func() string { return strconv.Itoa(getCPUThreads()) })
|
||||
start := time.Now().UnixMilli()
|
||||
memory := GetMemoryInfo()
|
||||
end := time.Now().UnixMilli()
|
||||
if showTimeTaken {
|
||||
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "MEM_*", end-start))
|
||||
}
|
||||
if memory != nil {
|
||||
env["MEM_TOTAL"] = strconv.Itoa(memory.MemTotal)
|
||||
env["MEM_USED"] = strconv.Itoa(memory.MemTotal - memory.MemAvailable)
|
||||
env["MEM_FREE"] = strconv.Itoa(memory.MemAvailable)
|
||||
}
|
||||
start = time.Now().UnixMilli()
|
||||
partitions := getMountedPartitions()
|
||||
end = time.Now().UnixMilli()
|
||||
if showTimeTaken {
|
||||
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "PARTITION_*", end-start))
|
||||
}
|
||||
if len(partitions) != 0 {
|
||||
env["MOUNTED_PARTITIONS"] = strconv.Itoa(len(partitions))
|
||||
for i, part := range partitions {
|
||||
@@ -128,22 +154,37 @@ func SetupFetchEnv() []string {
|
||||
if 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)+"_USED_SIZE"] = FormatBytes(part.UsedSize)
|
||||
env["PARTITION"+strconv.Itoa(i+1)+"_FREE_SIZE"] = FormatBytes(part.FreeSize)
|
||||
}
|
||||
}
|
||||
env["DE_WM"] = GetDEWM()
|
||||
env["USER_SHELL"] = GetShell()
|
||||
env["DISPLAY_PROTOCOL"] = GetDisplayProtocol()
|
||||
setVariable("DE_WM", func() string { return GetDEWM() })
|
||||
setVariable("USER_SHELL", func() string { return GetShell() })
|
||||
setVariable("DISPLAY_PROTOCOL", func() string { return GetDisplayProtocol() })
|
||||
setVariable("LIBC", func() string { return GetLibc() })
|
||||
setVariable("INIT_SYSTEM", func() string { return GetInitSystem() })
|
||||
start = time.Now().UnixMilli()
|
||||
monitors := getMonitorResolution()
|
||||
end = time.Now().UnixMilli()
|
||||
if showTimeTaken {
|
||||
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "MONITOR_*", end-start))
|
||||
}
|
||||
if len(monitors) != 0 {
|
||||
env["CONNECTED_MONITORS"] = strconv.Itoa(len(monitors))
|
||||
for i, monitor := range monitors {
|
||||
env["MONITOR"+strconv.Itoa(i+1)] = monitor
|
||||
}
|
||||
}
|
||||
start = time.Now().UnixMilli()
|
||||
gpus := getGPUNames()
|
||||
end = time.Now().UnixMilli()
|
||||
if showTimeTaken {
|
||||
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "GPU_*", end-start))
|
||||
}
|
||||
if len(gpus) != 0 {
|
||||
env["CONNECTED_GPUS"] = strconv.Itoa(len(gpus))
|
||||
for i, gpu := range gpus {
|
||||
@@ -210,7 +251,7 @@ func runStormfetch() {
|
||||
cmd := exec.Command("/bin/bash", fetchScriptPath)
|
||||
cmd.Dir = path.Dir(fetchScriptPath)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, SetupFetchEnv()...)
|
||||
cmd.Env = append(cmd.Env, SetupFetchEnv(TimeTaken)...)
|
||||
cmd.Env = append(cmd.Env, "C0=\033[0m")
|
||||
for key, value := range colorMap {
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value))
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 121 KiB |
@@ -121,22 +121,17 @@ func getCPUThreads() int {
|
||||
|
||||
func getGPUNames() []string {
|
||||
var ret []string
|
||||
null, _ := os.Open(os.DevNull)
|
||||
serr := os.Stderr
|
||||
os.Stderr = null
|
||||
gpu, err := ghw.GPU()
|
||||
defer null.Close()
|
||||
os.Stderr = serr
|
||||
cmd := exec.Command("/bin/bash", "-c", "lspci -v -m | grep 'VGA' -A6 | grep '^Device:' | sed 's/^Device://' | awk '{$1=$1};1'")
|
||||
bytes, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
for i, graphics := range gpu.GraphicsCards {
|
||||
if slices.Contains(config.HiddenGPUS, i+1) {
|
||||
for _, name := range strings.Split(string(bytes), "\n") {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
if graphics.DeviceInfo != nil {
|
||||
ret = append(ret, graphics.DeviceInfo.Product.Name)
|
||||
}
|
||||
ret = append(ret, name)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -231,6 +226,8 @@ func GetShell() string {
|
||||
return "Zsh " + runCommand("$SHELL --version | awk '{print $2}'")
|
||||
case "fish":
|
||||
return "Fish " + runCommand("$SHELL --version | awk '{print $3}'")
|
||||
case "nu":
|
||||
return "Nushell " + runCommand("$SHELL --version")
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -319,6 +316,7 @@ type partition struct {
|
||||
Device string
|
||||
MountPoint string
|
||||
Label string
|
||||
Type string
|
||||
TotalSize uint64
|
||||
UsedSize uint64
|
||||
FreeSize uint64
|
||||
@@ -328,6 +326,10 @@ func getMountedPartitions() []partition {
|
||||
mounts, err := mountinfo.GetMounts(func(info *mountinfo.Info) (skip, stop bool) {
|
||||
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")
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return nil
|
||||
@@ -340,16 +342,33 @@ func getMountedPartitions() []partition {
|
||||
}
|
||||
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
|
||||
for _, entry := range mounts {
|
||||
p := partition{
|
||||
entry.Source,
|
||||
entry.Mountpoint,
|
||||
"",
|
||||
entry.FSType,
|
||||
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 {
|
||||
p.Label = value
|
||||
}
|
||||
@@ -372,6 +391,55 @@ func getMountedPartitions() []partition {
|
||||
return partitions
|
||||
}
|
||||
|
||||
func GetInitSystem() string {
|
||||
runCommand := func(command string) string {
|
||||
cmd := exec.Command("/bin/bash", "-c", command)
|
||||
workdir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
cmd.Dir = workdir
|
||||
cmd.Env = os.Environ()
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
link, err := os.Readlink("/sbin/init")
|
||||
if err != nil {
|
||||
return "Unknown"
|
||||
}
|
||||
if path.Base(link) == "systemd" {
|
||||
return "Systemd " + runCommand("systemctl --version | head -1 | awk '{print $2}'")
|
||||
} else if path.Base(link) == "openrc-init" {
|
||||
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'")
|
||||
} else if path.Base(link) == "runit-init" {
|
||||
return "Runit"
|
||||
} else {
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
func GetLibc() string {
|
||||
cmd := exec.Command("/bin/bash", "-c", "find /usr/lib64/ -maxdepth 1 -name 'ld-*' | grep musl")
|
||||
if err := cmd.Run(); err != nil {
|
||||
cmd = exec.Command("/bin/bash", "-c", "ldd --version | head -1 | cut -d' ' -f4")
|
||||
bytes, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "Glibc"
|
||||
}
|
||||
return "Glibc " + strings.TrimSpace(string(bytes))
|
||||
}
|
||||
cmd = exec.Command("/bin/bash", "-c", "ldd 2>&1 | grep 'Version' | cut -d' ' -f2")
|
||||
bytes, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "Musl"
|
||||
}
|
||||
return "Musl " + strings.TrimSpace(string(bytes))
|
||||
}
|
||||
|
||||
func FormatBytes(bytes uint64) string {
|
||||
var suffixes [6]string
|
||||
suffixes[0] = "B"
|
||||
|
||||
Reference in New Issue
Block a user