func (rcLocalCrash) set(c *check.C) {
	partition.MakeWritable(c, common.BaseAltPartitionPath)
	defer partition.MakeReadonly(c, common.BaseAltPartitionPath)
	targetFile := fmt.Sprintf("%s/etc/rc.local", common.BaseAltPartitionPath)
	cli.ExecCommand(c, "sudo", "chmod", "a+xw", targetFile)

	cli.ExecCommandToFile(c, targetFile,
		"sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger")
}
func (s *failoverSuite) TestRCLocalCrash(c *check.C) {
	breakSnap := func(snapPath string) error {
		targetFile := filepath.Join(snapPath, "etc", "rc.local")
		cli.ExecCommand(c, "sudo", "chmod", "a+xw", targetFile)
		cli.ExecCommandToFile(c, targetFile,
			"sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger")
		return nil
	}
	s.testUpdateToBrokenVersion(c, "ubuntu-core.canonical", breakSnap)
}
func installService(c *check.C, serviceName, serviceCfg, servicesPath string) {
	// Create service file.
	cli.ExecCommand(c, "sudo", "chmod", "a+w", servicesPath)
	serviceFileName := fmt.Sprintf("%s.service", serviceName)
	serviceFilePath := filepath.Join(servicesPath, serviceFileName)
	cli.ExecCommandToFile(c, serviceFilePath, "sudo", "echo", serviceCfg)

	// Create requires directory.
	requiresDir := filepath.Join(servicesPath, systemdTargetRequiresDir)
	cli.ExecCommand(c, "sudo", "mkdir", "-p", requiresDir)

	// Symlink from the requires dir to the service file.
	cli.ExecCommand(c, "sudo", "ln", "-s", serviceFilePath,
		filepath.Join(requiresDir, serviceFileName),
	)
}
func installService(c *check.C, serviceName, serviceCfg, basePath string) {
	partition.MakeWritable(c, basePath)
	defer partition.MakeReadonly(c, basePath)

	// Create service file
	serviceFile := fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName)
	cli.ExecCommand(c, "sudo", "chmod", "a+w", fmt.Sprintf("%s%s", basePath, baseSystemdPath))
	cli.ExecCommandToFile(c, serviceFile, "sudo", "echo", serviceCfg)

	// Create requires directory
	requiresDirPart := fmt.Sprintf("%s/%s", baseSystemdPath, systemdTargetRequiresDir)
	requiresDir := fmt.Sprintf("%s%s", basePath, requiresDirPart)
	cli.ExecCommand(c, "sudo", "mkdir", "-p", requiresDir)

	// Symlink from the requires dir to the service file (with chroot for being
	// usable in the other partition)
	cli.ExecCommand(c, "sudo", "chroot", basePath, "ln", "-s",
		fmt.Sprintf("%s/%s.service", baseSystemdPath, serviceName),
		fmt.Sprintf("%s/%s.service", requiresDirPart, serviceName),
	)
}