1
0
mirror of https://github.com/rancher/os.git synced 2025-09-04 00:04:25 +00:00
Files
os/cmd/ros-installer/main.go

40 lines
960 B
Go
Raw Normal View History

2021-08-31 11:14:03 -07:00
package main
import (
"flag"
2021-10-13 16:00:29 -07:00
"os"
2021-08-31 11:14:03 -07:00
2021-10-20 12:19:44 -07:00
"github.com/rancher/os2/pkg/config"
"github.com/rancher/os2/pkg/install"
2021-08-31 11:14:03 -07:00
"github.com/sirupsen/logrus"
2021-10-13 16:00:29 -07:00
"sigs.k8s.io/yaml"
2021-08-31 11:14:03 -07:00
)
var (
2021-10-22 23:22:09 -07:00
automatic = flag.Bool("automatic", false, "Check for and run automatic installation")
2021-10-13 16:00:29 -07:00
printConfig = flag.Bool("print-config", false, "Print effective configuration and exit")
configFile = flag.String("config-file", "", "Config file to use, local file or http/tftp URL")
2021-10-29 12:20:35 -07:00
powerOff = flag.Bool("power-off", false, "Power off after installation")
yes = flag.Bool("y", false, "Do not prompt for questions")
2021-08-31 11:14:03 -07:00
)
func main() {
flag.Parse()
2021-10-13 16:00:29 -07:00
if *printConfig {
2021-11-03 22:06:12 -07:00
cfg, err := config.ReadConfig(*configFile, *automatic)
2021-10-13 16:00:29 -07:00
if err != nil {
logrus.Fatal(err)
}
data, err := yaml.Marshal(cfg)
if err != nil {
logrus.Fatal(err)
}
os.Stdout.Write(data)
return
}
2021-10-29 12:20:35 -07:00
if err := install.Run(*automatic, *configFile, *powerOff, *yes); err != nil {
2021-08-31 11:14:03 -07:00
logrus.Fatal(err)
}
}