Call sysctl on boot

This commit is contained in:
2026-04-16 15:42:59 +03:00
parent b64d6984be
commit eb424b0416
+19
View File
@@ -51,6 +51,8 @@ func main() {
mountVirtualFilesystems()
// Mount filesystems in fstab
mountFilesystems()
// Run sysctl
initSysctl()
// Set hostname
setHostname()
// Start service manager
@@ -220,6 +222,23 @@ func killProcesses() {
fmt.Println("Done.")
}
func initSysctl() {
// Return if sysctl cannot be found
if _, err := os.Stat("/sbin/sysctl"); err != nil {
return
}
fmt.Print("Running sysctl...")
err := exec.Command("/sbin/sysctl", "--system").Run()
if err != nil {
log.Println("Failed!")
return
}
fmt.Println("Done.")
}
func setHostname() {
fmt.Print("Setting hostname... ")