From 7feee617a788a90cb5cf6fca8aae28162ff0739d Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 12 Sep 2017 13:54:28 +1000 Subject: [PATCH] Log autoformat script output to /var/log/boot/autoformat.log Signed-off-by: Sven Dowideit --- cmd/control/bootstrap.go | 3 +++ images/02-bootstrap/auto-format.sh | 1 + init/init.go | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/control/bootstrap.go b/cmd/control/bootstrap.go index 9ccaf118..6ba41c63 100644 --- a/cmd/control/bootstrap.go +++ b/cmd/control/bootstrap.go @@ -15,6 +15,9 @@ import ( ) func bootstrapAction(c *cli.Context) error { + log.InitLogger() + log.Info("Running cloud-init-save") + log.Debugf("bootstrapAction") if err := UdevSettle(); err != nil { log.Errorf("Failed to run udev settle: %v", err) diff --git a/images/02-bootstrap/auto-format.sh b/images/02-bootstrap/auto-format.sh index 48e7994c..b8f207cc 100755 --- a/images/02-bootstrap/auto-format.sh +++ b/images/02-bootstrap/auto-format.sh @@ -1,4 +1,5 @@ #!/bin/bash +exec &>> /var/log/boot/autoformat.log set -ex MAGIC=${MAGIC:-"boot2docker, please format-me"} diff --git a/init/init.go b/init/init.go index 967dba69..ee3302ba 100755 --- a/init/init.go +++ b/init/init.go @@ -359,11 +359,20 @@ func RunInit() error { } // And all the files in /var/log/boot/ // TODO: I wonder if we can put this code into the log module, and have things write to the buffer until we FsReady() - bootLog := "/var/log/boot/" + bootLog := "/var/log/" if files, err := ioutil.ReadDir(bootLog); err == nil { for _, file := range files { filePath := filepath.Join(bootLog, file.Name()) filesToCopy = append(filesToCopy, filePath) + log.Debugf("Swizzle: Found %s to save", filePath) + } + } + bootLog = "/var/log/boot/" + if files, err := ioutil.ReadDir(bootLog); err == nil { + for _, file := range files { + filePath := filepath.Join(bootLog, file.Name()) + filesToCopy = append(filesToCopy, filePath) + log.Debugf("Swizzle: Found %s to save", filePath) } } for _, name := range filesToCopy { @@ -373,7 +382,7 @@ func RunInit() error { log.Errorf("read cfg file (%s) %s", name, err) continue } - log.Debugf("Saved %s to memory", name) + log.Debugf("Swizzle: Saved %s to memory", name) configFiles[name] = content } } @@ -405,7 +414,7 @@ func RunInit() error { if err := util.WriteFileAtomic(name, content, fileMode); err != nil { log.Error(err) } - log.Infof("Wrote log to %s", name) + log.Infof("Swizzle: Wrote file to %s", name) } if err := os.MkdirAll(config.VarRancherDir, os.ModeDir|0755); err != nil { log.Error(err)