Skip to content

Commit

Permalink
Update users.go
Browse files Browse the repository at this point in the history
  • Loading branch information
referefref authored Jul 2, 2024
1 parent 9be0823 commit e158173
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions users.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
package main

import (
"fmt"
"math/rand"
"os/exec"
"time"
)

func performScheduledTasks(config *Config) {
tasks := selectRandomOrHardcodedScheduledTasks(config.ScheduledTasks.Options, config.ScheduledTasks.SelectionMethod)
for _, task := range tasks {
cmd := exec.Command("schtasks", "/create", "/tn", task.Name, "/tr", task.Path, "/sc", task.Schedule, "/st", task.StartTime)
err := cmd.Run()
if err != nil {
logToFile(config.General.LogFile, fmt.Sprintf("Failed to create scheduled task %s: %v", task.Name, err))
} else {
logToFile(config.General.LogFile, fmt.Sprintf("Created scheduled task %s", task.Name))
}
time.Sleep(time.Duration(config.General.ActionDelay+rand.Intn(2*config.General.RandomnessFactor+1)-config.General.RandomnessFactor) * time.Second)
}
}

func selectRandomOrHardcodedScheduledTasks(options []ScheduledTask, method string) []ScheduledTask {
if method == "hardcoded" {
return options
}
rand.Seed(time.Now().UnixNano())
return []ScheduledTask{options[rand.Intn(len(options))]}
}

root@mainwebsite:/home/ref/sinonv2# cat users.go
package main

import (
"fmt"

Expand Down

0 comments on commit e158173

Please sign in to comment.