inits/cmd/dkl-system-init/udev.go

37 lines
836 B
Go
Raw Normal View History

2018-07-06 08:07:37 +00:00
package main
import (
"io/ioutil"
"os"
)
func init() {
services.Register(
&CommandService{
Name: "udev",
Restart: StdRestart,
Needs: []string{"service:devfs", "service:dmesg", "service:lvm"},
PreExec: func() error {
if _, err := os.Stat("/proc/net/unix"); os.IsNotExist(err) {
run("modprobe", "unix")
}
if _, err := os.Stat("/proc/sys/kernel/hotplug"); err == nil {
ioutil.WriteFile("/proc/sys/kernel/hotplug", []byte{}, 0644)
}
return nil
},
Command: []string{"/lib/systemd/systemd-udevd"},
},
&CommandService{
Name: "udev trigger",
Needs: []string{"service:udev"},
Command: []string{"udevadm", "trigger"},
},
&CommandService{
Name: "udev settle",
Needs: []string{"service:udev trigger"},
Command: []string{"udevadm", "settle"},
},
)
}