mirror of
https://github.com/rancher/os.git
synced 2025-09-16 15:09:27 +00:00
Get RancherOS logging to throw debug logs to a remote syslog server when the kernel netconsole is configured
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -108,7 +108,10 @@ func ApplyConsole(cfg *rancherConfig.CloudConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
util.RunCommandSequence(cfg.Runcmd)
|
||||
err := util.RunCommandSequence(cfg.Runcmd)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func WriteFiles(cfg *rancherConfig.CloudConfig, container string) {
|
||||
|
@@ -39,7 +39,10 @@ func bootstrapAction(c *cli.Context) error {
|
||||
}
|
||||
|
||||
log.Debugf("bootstrapAction: RunCommandSequence(%v)", cfg.Bootcmd)
|
||||
util.RunCommandSequence(cfg.Bootcmd)
|
||||
err := util.RunCommandSequence(cfg.Bootcmd)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if cfg.Rancher.State.Dev != "" && cfg.Rancher.State.Wait {
|
||||
waitForRoot(cfg)
|
||||
|
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/config/cmdline"
|
||||
"github.com/rancher/os/log"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
@@ -63,7 +64,7 @@ func consoleInitFunc() error {
|
||||
createHomeDir(rancherHome, 1100, 1100)
|
||||
createHomeDir(dockerHome, 1101, 1101)
|
||||
|
||||
password := config.GetCmdline("rancher.password")
|
||||
password := cmdline.GetCmdline("rancher.password")
|
||||
if password != "" {
|
||||
cmd := exec.Command("chpasswd")
|
||||
cmd.Stdin = strings.NewReader(fmt.Sprint("rancher:", password))
|
||||
|
@@ -368,7 +368,11 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka
|
||||
func mountBootIso() error {
|
||||
deviceName := "/dev/sr0"
|
||||
deviceType := "iso9660"
|
||||
if d, t := util.Blkid("RancherOS"); d != "" {
|
||||
d, t, err := util.Blkid("RancherOS")
|
||||
if err != nil {
|
||||
log.Errorf("Failed to run blkid: %s", err)
|
||||
}
|
||||
if d != "" {
|
||||
deviceName = d
|
||||
deviceType = t
|
||||
}
|
||||
@@ -728,6 +732,66 @@ func formatdevice(device, partition string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func mountdevice(baseName, bootDir, device, partition string, raw bool) (string, string, error) {
|
||||
log.Debugf("mountdevice %s, raw %v", partition, raw)
|
||||
|
||||
if partition == "" {
|
||||
if raw {
|
||||
log.Debugf("util.Mount (raw) %s, %s", partition, baseName)
|
||||
|
||||
cmd := exec.Command("lsblk", "-no", "pkname", partition)
|
||||
log.Debugf("Run(%v)", cmd)
|
||||
cmd.Stderr = os.Stderr
|
||||
device := ""
|
||||
// TODO: out can == "" - this is used to "detect software RAID" which is terrible
|
||||
if out, err := cmd.Output(); err == nil {
|
||||
device = "/dev/" + strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
log.Debugf("mountdevice return -> d: %s, p: %s", device, partition)
|
||||
return device, partition, util.Mount(partition, baseName, "", "")
|
||||
}
|
||||
|
||||
//rootfs := partition
|
||||
// Don't use ResolveDevice - it can fail, whereas `blkid -L LABEL` works more often
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
d, _, err := util.Blkid("RANCHER_BOOT")
|
||||
if err != nil {
|
||||
log.Errorf("Failed to run blkid: %s", err)
|
||||
}
|
||||
if d != "" {
|
||||
partition = d
|
||||
baseName = filepath.Join(baseName, "boot")
|
||||
} else {
|
||||
if dev := util.ResolveDevice(cfg.Rancher.State.Dev); dev != "" {
|
||||
// try the rancher.state.dev setting
|
||||
partition = dev
|
||||
} else {
|
||||
d, _, err := util.Blkid("RANCHER_STATE")
|
||||
if err != nil {
|
||||
log.Errorf("Failed to run blkid: %s", err)
|
||||
}
|
||||
if d != "" {
|
||||
partition = d
|
||||
}
|
||||
}
|
||||
}
|
||||
cmd := exec.Command("lsblk", "-no", "pkname", partition)
|
||||
log.Debugf("Run(%v)", cmd)
|
||||
cmd.Stderr = os.Stderr
|
||||
// TODO: out can == "" - this is used to "detect software RAID" which is terrible
|
||||
if out, err := cmd.Output(); err == nil {
|
||||
device = "/dev/" + strings.TrimSpace(string(out))
|
||||
}
|
||||
}
|
||||
os.MkdirAll(baseName, 0755)
|
||||
cmd := exec.Command("mount", partition, baseName)
|
||||
//cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||
log.Debugf("mountdevice return2 -> d: %s, p: %s", device, partition)
|
||||
return device, partition, cmd.Run()
|
||||
}
|
||||
|
||||
func formatAndMount(baseName, device, partition string) (string, string, error) {
|
||||
log.Debugf("formatAndMount")
|
||||
|
||||
|
@@ -47,7 +47,11 @@ func MountDevice(baseName, device, partition string, raw bool) (string, string,
|
||||
// Don't use ResolveDevice - it can fail, whereas `blkid -L LABEL` works more often
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
if d, _ := util.Blkid("RANCHER_BOOT"); d != "" {
|
||||
d, _, err := util.Blkid("RANCHER_BOOT")
|
||||
if err != nil {
|
||||
log.Errorf("Failed to run blkid: %s", err)
|
||||
}
|
||||
if d != "" {
|
||||
partition = d
|
||||
baseName = filepath.Join(baseName, BootDir)
|
||||
} else {
|
||||
@@ -55,7 +59,11 @@ func MountDevice(baseName, device, partition string, raw bool) (string, string,
|
||||
// try the rancher.state.dev setting
|
||||
partition = dev
|
||||
} else {
|
||||
if d, _ := util.Blkid("RANCHER_STATE"); d != "" {
|
||||
d, _, err := util.Blkid("RANCHER_STATE")
|
||||
if err != nil {
|
||||
log.Errorf("Failed to run blkid: %s", err)
|
||||
}
|
||||
if d != "" {
|
||||
partition = d
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user