2024-09-29 20:53:33 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-13 15:01:38 +02:00
|
|
|
|
2024-09-29 20:53:33 +02:00
|
|
|
"github.com/ansible-semaphore/semaphore/cli/setup"
|
|
|
|
"github.com/ansible-semaphore/semaphore/util"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
runnerCmd.AddCommand(runnerSetupCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var runnerSetupCmd = &cobra.Command{
|
|
|
|
Use: "setup",
|
|
|
|
Short: "Perform interactive setup",
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
doRunnerSetup()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// nolint: gocyclo
|
|
|
|
func doRunnerSetup() int {
|
2024-10-13 15:10:54 +02:00
|
|
|
config := &util.ConfigType{}
|
2024-09-29 20:53:33 +02:00
|
|
|
|
|
|
|
setup.InteractiveRunnerSetup(config)
|
|
|
|
|
2024-10-13 15:01:38 +02:00
|
|
|
resultConfigPath := setup.SaveConfig(config, "config-runner.json", persistentFlags.configPath)
|
2024-09-29 20:53:33 +02:00
|
|
|
|
2024-09-29 22:18:08 +02:00
|
|
|
util.ConfigInit(resultConfigPath, false)
|
2024-09-29 20:53:33 +02:00
|
|
|
|
2024-09-29 22:18:08 +02:00
|
|
|
fmt.Printf(" Re-launch this program pointing to the configuration file\n\n./semaphore runner --config %v\n\n", resultConfigPath)
|
|
|
|
fmt.Printf(" To run as daemon:\n\nnohup ./semaphore runner --config %v &\n\n", resultConfigPath)
|
2024-09-29 20:53:33 +02:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|