Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BrewCmd = &cobra.Command{ Use: "brew", Short: "Update Homebrew packages only", Long: `This command updates only Homebrew packages, skipping system updates.`, Run: func(cmd *cobra.Command, args []string) { isVerbose := utils.IsVerbose(cmd) updateBrew(isVerbose) }, }
View Source
var CompauditFixCmd = &cobra.Command{ Use: "compauditFix", Short: "Fix insecure directories reported by compaudit", Long: `Runs 'compaudit' and applies 'chmod g-w,o-w' to any directories reported as insecure. This uses an interactive zsh so zsh functions like compaudit (from oh-my-zsh) are available.`, Run: func(cmd *cobra.Command, args []string) { log.Start("Running compaudit and fixing insecure directories...") isVerbose := utils.IsVerbose(cmd) execCmd := exec.Command("zsh", "-ic", "compaudit | xargs --no-run-if-empty chmod g-w,o-w") log.Verbose(isVerbose, "Executing: %s", execCmd.String()) outputBytes, err := execCmd.CombinedOutput() output := strings.TrimSpace(string(outputBytes)) if err != nil { log.Error("Failed to run compaudit fix: %v", err) if output != "" { log.Error("Output: %s", output) } return } if output != "" { log.Message("%s", output) } log.Success("Finished applying compaudit fixes.") }, }
CompauditFixCmd runs 'compaudit' and removes group/world write permissions from any reported insecure directories.
View Source
var KillPortCmd = &cobra.Command{ Use: "killPort [port]", Short: "Find and kill the process listening on a specific port", Long: `This command finds the process ID (PID) listening on the specified network port using the 'lsof' command and then terminates that process forcefully using 'kill -9'. Requires 'lsof' and 'kill' commands to be available on the system. Primarily intended for Unix-like systems (Linux, macOS).`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { portStr := args[0] isVerbose := utils.IsVerbose(cmd) if _, err := strconv.Atoi(portStr); err != nil { log.Error("Invalid port number provided: %s. Port must be an integer.", portStr) return } log.Message("Attempting to find process on port %s...", portStr) lsofCmd := exec.Command("lsof", "-ti:"+portStr) log.Verbose(isVerbose, "Executing: %s", lsofCmd.String()) outputBytes, err := lsofCmd.CombinedOutput() output := strings.TrimSpace(string(outputBytes)) if err != nil { log.Verbose(isVerbose, "lsof command finished with error: %v", err) log.Verbose(isVerbose, "lsof output: %s", output) if _, ok := err.(*exec.ExitError); ok && output == "" { log.Warn("No process found listening on port %s.", portStr) } else { log.Error("Failed to execute lsof command: %v", err) log.Error("lsof output (if any): %s", output) } return } if output == "" { log.Warn("lsof ran successfully but found no process ID on port %s.", portStr) return } pids := strings.Fields(output) if len(pids) == 0 { log.Warn("lsof command returned empty output after trimming.") return } killedCount := 0 errorCount := 0 for _, pid := range pids { log.Info("Found process with PID %s on port %s. Attempting to kill...", pid, portStr) killCmd := exec.Command("kill", "-9", pid) log.Verbose(isVerbose, "Executing: %s", killCmd.String()) if err := killCmd.Run(); err != nil { log.Error("Failed to kill process with PID %s: %v", pid, err) errorCount++ } else { log.Success("Successfully sent kill signal to process with PID %s.", pid) killedCount++ } } if killedCount > 0 && errorCount == 0 { log.Success("Finished killing process(es) on port %s.", portStr) } else if killedCount > 0 && errorCount > 0 { log.Warn("Finished attempting to kill process(es) on port %s, but encountered %d error(s).", portStr, errorCount) } else if killedCount == 0 && errorCount > 0 { log.Error("Failed to kill any process found on port %s.", portStr) } }, }
View Source
var ProxyCmd = &cobra.Command{ Use: "proxy", Short: "Show or configure system proxies", Long: `This command displays and manages multiple proxy configurations and allows enabling, disabling, or setting them via subcommands.`, Run: func(cmd *cobra.Command, args []string) { listProxyConfigurations() }, }
View Source
var SetupASDFCmd = &cobra.Command{ Use: "asdf", Short: "Setup asdf plugins from $HOME/.tool-versions", Long: `Reads $HOME/.tool-versions and installs asdf plugins listed there.`, Run: func(cmd *cobra.Command, args []string) { setupASDF() }, }
View Source
var SetupCmd = &cobra.Command{
Use: "setup",
Short: "Setup development tools",
Long: `Setup various development tools. Example: eng system setup asdf`,
}
View Source
var SystemCmd = &cobra.Command{ Use: "system", Short: "A command for managing the system", Long: `This command will help manage various aspects of MacOS and Linux systems.`, Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() cobra.CheckErr(err) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Aliases: []string{"update", "u"}, Short: "Update the system", Long: `This command updates the system. It supports Ubuntu and WSL Linux systems and logs a message for unsupported systems.`, Run: func(cmd *cobra.Command, args []string) { isVerbose := utils.IsVerbose(cmd) log.Verbose(isVerbose, "Checking system type...") checkCmd := exec.Command("uname", "-a") output, err := checkCmd.Output() if err != nil { log.Error("Error checking system type: %s", err) return } uname := strings.ToLower(string(output)) log.Verbose(isVerbose, "System type detected: %s", strings.TrimSpace(string(output))) if strings.Contains(uname, "ubuntu") || strings.Contains(uname, "linux") { log.Verbose(isVerbose, "Detected Ubuntu/Linux system, running system update...") updateUbuntu(isVerbose) } else if strings.Contains(uname, "darwin") { log.Verbose(isVerbose, "Detected macOS system, running macOS update...") updateMacOS(isVerbose) } else if strings.Contains(uname, "raspberrypi") || strings.Contains(uname, "raspbian") { log.Verbose(isVerbose, "Detected Raspberry Pi system, running Raspberry Pi update...") updateRaspberryPi(isVerbose) } else { log.Warn("This system is not yet supported for updates.") log.Verbose(isVerbose, "Unsupported system type: %s", strings.TrimSpace(string(output))) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.