123456789101112131415161718192021222324252627 |
- package main
- import (
- "fmt"
- "os/exec"
- )
- // commandExists checks if a given command exists on the system
- func commandExists(cmd string) bool {
- _, err := exec.LookPath(cmd)
- return err == nil
- }
- // checkRuntimeEnvironment checks if the required commands are available in the runtime environment
- func checkRuntimeEnvironment() bool {
- packageMissing := false
- commands := []string{"ffmpeg", "smartctl", "mdadm", "lsblk", "blkid", "df"}
- for _, cmd := range commands {
- if commandExists(cmd) {
- fmt.Printf("\033[32m✔\033[0m '%s' exists\n", cmd)
- } else {
- packageMissing = true
- fmt.Printf("\033[31m✘\033[0m '%s' does not exist\n", cmd)
- }
- }
- return !packageMissing
- }
|