setup: WriteToFile primitive

Add a new `WriteToFile` primitive plus a usecase for it.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2024-10-28 11:49:07 +01:00
parent bea17a4077
commit 3ad2d0cd4c
No known key found for this signature in database
2 changed files with 11 additions and 11 deletions

View file

@ -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
}

View file

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