posadka/modify.go
Simon de Vlieger 3ad2d0cd4c
setup: WriteToFile primitive
Add a new `WriteToFile` primitive plus a usecase for it.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-10-28 11:50:03 +01:00

40 lines
730 B
Go

package posadka
import (
"path/filepath"
)
func EmptyRootPassword(prefix string) error {
path := filepath.Join(prefix, "etc/passwd")
return ReplaceInFile(
path,
[]byte("root:x:"),
[]byte("root::"),
)
}
func EnableSystemRequest(prefix string) error {
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 {
path := filepath.Join(prefix, "etc/passwd")
//# remove quiet from kargs
//if [ "$SHOWBOOT" != "" ]; then
// sed -i 's|rhgb quiet ||g' /tmp/boot/loader/entries/*.conf
//fi
return ReplaceInFile(
path,
[]byte("rhgb quiet "),
[]byte(""),
)
}