-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd07029
commit 59584ff
Showing
197 changed files
with
47,015 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/_exe |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/sgsullivan/befehl" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var payload string | ||
var routines int | ||
var hostsList string | ||
|
||
var executeCmd = &cobra.Command{ | ||
Use: "execute", | ||
Short: "Execute the given payload against the given hosts list", | ||
Long: `Executes the given payload on each host in the hosts list. Hosts in the hosts | ||
list should be separated by a new line. You can control how many payloads run concurrently by | ||
passing the routines flag. | ||
By default befehl will use the private key in $HOME/.ssh/id_rsa. This can be overrode by | ||
specifying auth.privatekeyfile in ~/.befehl.[toml|json|yaml]. | ||
By default befehl will write the output of each payload for each host in $HOME/befehl/logs. This | ||
can be overrode by specifying general.logdir in ~/.befehl.[toml|json|yaml]. | ||
By default befehl will attempt to ssh as root. This can be overrode by specifying auth.sshuser | ||
in ~/.befehl.[toml|json|yaml]. | ||
Heres an example specifying all of the above mentioned options: | ||
[general] | ||
logdir = "/home/ssullivan/log-special" | ||
[auth] | ||
privatekeyfile = "/home/ssullivan/alt/id_rsa" | ||
sshuser = "eingeben" | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, value := range []string{payload, hostsList} { | ||
if value == "" { | ||
panic("Missing payload, or hosts; see --help") | ||
} | ||
if routines == 0 { | ||
fmt.Printf("--routines not given, defaulting to 30..\n") | ||
routines = 30 | ||
} | ||
} | ||
befehl.Fire(&hostsList, &payload, &routines, Config) | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(executeCmd) | ||
executeCmd.Flags().StringVarP(&payload, "payload", "", "", "file location to the payload, which contains the commands to execute on the remote hosts") | ||
executeCmd.Flags().StringVarP(&hostsList, "hosts", "", "", "file location to hosts list, which contains all hosts (separated by newline) to run the payload on") | ||
executeCmd.Flags().IntVarP(&routines, "routines", "", 0, "maximum number of payloads that will run at once (defaults to 30)") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"os" | ||
) | ||
|
||
var Config *viper.Viper | ||
|
||
var RootCmd = &cobra.Command{ | ||
Use: "befehl", | ||
Short: "ausführen willkürliche Befehle über ssh in Masse", | ||
Long: `Gegeben ein Gastgeberliste, ausführen Nutzlast über ssh Auf jedem Host. | ||
Dieses Werkzeug sollte mit Vorsicht verwendet werden; gegeben das Macht angeboten.`, | ||
} | ||
|
||
func Execute() { | ||
if err := RootCmd.Execute(); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func init() { | ||
cobra.OnInitialize(initConfig) | ||
} | ||
|
||
func initConfig() { | ||
thisViper := viper.New() | ||
thisViper.SetConfigName(".befehl") | ||
configDir := os.Getenv("HOME") | ||
if os.Getenv("BEFEHL_CONFIG_DIR") != "" { | ||
configDir = os.Getenv("BEFEHL_CONFIG_DIR") | ||
} | ||
thisViper.AddConfigPath(configDir) | ||
if err := thisViper.ReadInConfig(); err != nil { | ||
fmt.Printf("Failed reading config (using defaults) [%s]: [%s]\n", thisViper.ConfigFileUsed(), err) | ||
} | ||
Config = thisViper | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/sgsullivan/befehl/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.