Skip to content

Commit

Permalink
Fix sudo warning
Browse files Browse the repository at this point in the history
  • Loading branch information
metaspartan committed Apr 27, 2024
1 parent 6c44842 commit e08741f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ func setupUI() {

func setupGrid() {
grid = ui.NewGrid()

// Define the rows and columns
grid.Set(
ui.NewRow(1.0/2, // This row now takes half the height of the grid
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))),
Expand Down Expand Up @@ -211,8 +209,6 @@ func switchGridLayout() {
ui.NewCol(2.0/6, NetworkInfo),
),
)

// Set the new grid's dimensions to match the terminal size
termWidth, termHeight := ui.TerminalDimensions()
newGrid.SetRect(0, 0, termWidth, termHeight)
grid = newGrid
Expand All @@ -237,7 +233,6 @@ func switchGridLayout() {
ui.NewCol(1.0, memoryGauge),
),
)
// Set the new grid's dimensions to match the terminal size
termWidth, termHeight := ui.TerminalDimensions()
newGrid.SetRect(0, 0, termWidth, termHeight)
grid = newGrid
Expand All @@ -250,16 +245,12 @@ func StderrToLogfile(logfile *os.File) {
syscall.Dup2(int(logfile.Fd()), 2)
}

func main() {
// goasitop main function

if os.Geteuid() != 0 && len(os.Args) > 1 && os.Args[1] != "--test" {
fmt.Println("Welcome to goasitop! Please try again and run goasitop with sudo privileges!")
fmt.Println("Usage: sudo goasitop")
os.Exit(1)
}
func main() {

// get version from git
version := "v0.1.0"
version := "v0.1.1"
if len(os.Args) > 1 && os.Args[1] == "--version" {
fmt.Println("goasitop version:", version)
os.Exit(0)
Expand All @@ -271,6 +262,12 @@ func main() {
os.Exit(0)
}

if os.Geteuid() != 0 {
fmt.Println("Welcome to goasitop! Please try again and run goasitop with sudo privileges!")
fmt.Println("Usage: sudo goasitop")
os.Exit(1)
}

logfile, err := setupLogfile()
if err != nil {
stderrLogger.Fatalf("failed to setup log file: %v", err)
Expand Down

0 comments on commit e08741f

Please sign in to comment.