Simon de Vlieger
3ad2d0cd4c
Add a new `WriteToFile` primitive plus a usecase for it. Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
40 lines
730 B
Go
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(""),
|
|
)
|
|
}
|