Exemplo n.º 1
0
// RebootWithMark requests a reboot using a specified mark.
func RebootWithMark(c *check.C, mark string) {
	c.Log("Preparing reboot with mark " + mark)
	err := ioutil.WriteFile(NeedsRebootFile, []byte(mark), 0777)
	c.Assert(err, check.IsNil, check.Commentf("Error writing needs-reboot file: %v", err))
	mode, err := partition.Mode()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the bootloader mode: %v", err))
	if mode == "try" {
		p, err := partition.NextBootPartition()
		c.Assert(err, check.IsNil, check.Commentf("Error getting the next boot partition: %v", err))
		c.Logf("Will reboot in try mode to partition %s", p)
	}
}
// newKernelFilenamePattern returns the filename pattern to modify files
// in the partition declared in the boot config file.
//
// After the update, the config file is already changed to point to the new partition.
// If we are on a and update, the config file would point to b
// and this function would return "b/%s%s*"
// If we are not in an update process (ie. we are unsetting the failover conditions)
// we want to change the files in the other partition
func newKernelFilenamePattern(c *check.C, bootSystem string, afterUpdate bool) string {
	var part string
	var err error
	if afterUpdate {
		part, err = partition.NextBootPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the next boot partition: %s", err))
	} else {
		part, err = partition.CurrentPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the current partition: %s", err))
		part = partition.OtherPartition(part)
	}
	return filepath.Join(part, "%s%s*")
}