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 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), ) }