From 3ad2d0cd4cef4c8b87f8dc36be1b5b6359f481c8 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Mon, 28 Oct 2024 11:49:07 +0100 Subject: [PATCH] setup: `WriteToFile` primitive Add a new `WriteToFile` primitive plus a usecase for it. Signed-off-by: Simon de Vlieger --- modify.go | 18 +++++++----------- primitive.go | 4 ++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modify.go b/modify.go index a08dc08..d958dd7 100644 --- a/modify.go +++ b/modify.go @@ -15,15 +15,13 @@ func EmptyRootPassword(prefix string) error { } func EnableSystemRequest(prefix string) error { - //579 # Enable System Request debugging of the kernel - //580 if [ "$SYSRQ" != "" ]; then - //581 echo "= Enabling System Request debugging of the kernel." - //582 cat >> ${PREFIX}/etc/sysctl.d/arm-image-installer-sysrq.conf <<-EOH - //583 # Controls the System Request debugging functionality of the kernel - //584 kernel.sysrq = 1 - //585 EOH - //586 fi - return nil + path := filepath.Join(prefix, "etc/sysctl.d/posadka-sysrq.conf") + + // TODO, might want an append instead? + return WriteToFile( + path, + []byte("kernel.sysrq = 1\n"), + ) } func ShowBoot(prefix string) error { @@ -39,6 +37,4 @@ func ShowBoot(prefix string) error { []byte("rhgb quiet "), []byte(""), ) - - return nil } diff --git a/primitive.go b/primitive.go index 5797c91..3a1f083 100644 --- a/primitive.go +++ b/primitive.go @@ -29,3 +29,7 @@ func ReplaceInFile(path string, a, b []byte) error { return nil } + +func WriteToFile(path string, data []byte) error { + return os.WriteFile(path, data, 0644) +}