1
0
mirror of https://github.com/rancher/os.git synced 2025-05-10 00:56:20 +00:00

Start rngd before format the disk

This commit is contained in:
niusmallnan 2018-09-14 16:34:09 +08:00 committed by niusmallnan
parent 07226313b4
commit d7f47925a1
4 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,13 @@ func BootstrapMain() {
log.Debugf("bootstrapAction: loadingConfig")
cfg := config.LoadConfig()
log.Debugf("bootstrapAction: Rngd(%v)", cfg.Rancher.State.Rngd)
if cfg.Rancher.State.Rngd {
if err := runRngd(); err != nil {
log.Errorf("Failed to run rngd: %v", err)
}
}
log.Debugf("bootstrapAction: MdadmScan(%v)", cfg.Rancher.State.MdadmScan)
if cfg.Rancher.State.MdadmScan {
if err := mdadmScan(); err != nil {
@ -68,6 +75,13 @@ func mdadmScan() error {
return cmd.Run()
}
func runRngd() error {
cmd := exec.Command("rngd", "-q")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
func runStateScript(script string) error {
f, err := ioutil.TempFile("", "")
if err != nil {

View File

@ -169,6 +169,7 @@ var schema = `{
"required": {"type": "boolean"},
"autoformat": {"$ref": "#/definitions/list_of_strings"},
"mdadm_scan": {"type": "boolean"},
"rngd": {"type": "boolean"},
"script": {"type": "string"},
"oem_fstype": {"type": "string"},
"oem_dev": {"type": "string"}

View File

@ -206,6 +206,7 @@ type StateConfig struct {
Required bool `yaml:"required,omitempty"`
Autoformat []string `yaml:"autoformat,omitempty"`
MdadmScan bool `yaml:"mdadm_scan,omitempty"`
Rngd bool `yaml:"rngd,omitempty"`
Script string `yaml:"script,omitempty"`
OemFsType string `yaml:"oem_fstype,omitempty"`
OemDev string `yaml:"oem_dev,omitempty"`

View File

@ -82,6 +82,7 @@ rancher:
fstype: auto
oem_fstype: auto
oem_dev: LABEL=RANCHER_OEM
rngd: true
sysctl:
fs.file-max: 1000000000
services: