feat: logic for scripts and webhooks
All checks were successful
build / build (push) Successful in 2m18s
All checks were successful
build / build (push) Successful in 2m18s
This commit is contained in:
@@ -1,9 +1,32 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/d3m0k1d/BanForge/internal/config"
|
||||
)
|
||||
|
||||
func RunScript(action config.Action) error {
|
||||
if !action.Enabled {
|
||||
return nil
|
||||
}
|
||||
if action.Script == "" {
|
||||
return fmt.Errorf("script on config is empty")
|
||||
}
|
||||
if action.Interpretator == "" {
|
||||
// #nosec G204 - managed by system adminstartor
|
||||
cmd := exec.Command(action.Script)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("run script: %w", err)
|
||||
}
|
||||
}
|
||||
// #nosec G204 - managed by system adminstartor
|
||||
cmd := exec.Command(action.Interpretator, action.Script)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("run script: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user