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 { func EnableSystemRequest(prefix string) error {
//579 # Enable System Request debugging of the kernel path := filepath.Join(prefix, "etc/sysctl.d/posadka-sysrq.conf")
//580 if [ "$SYSRQ" != "" ]; then
//581 echo "= Enabling System Request debugging of the kernel." // TODO, might want an append instead?
//582 cat >> ${PREFIX}/etc/sysctl.d/arm-image-installer-sysrq.conf <<-EOH return WriteToFile(
//583 # Controls the System Request debugging functionality of the kernel path,
//584 kernel.sysrq = 1 []byte("kernel.sysrq = 1\n"),
//585 EOH )
//586 fi
return nil
} }
func ShowBoot(prefix string) error { func ShowBoot(prefix string) error {
@ -39,6 +37,4 @@ func ShowBoot(prefix string) error {
[]byte("rhgb quiet "), []byte("rhgb quiet "),
[]byte(""), []byte(""),
) )
return nil
} }

View file

@ -29,3 +29,7 @@ func ReplaceInFile(path string, a, b []byte) error {
return nil return nil
} }
func WriteToFile(path string, data []byte) error {
return os.WriteFile(path, data, 0644)
}