Пример #1
0
func runReboot(args []string) int {
	elc, _ := lock.NewEtcdLockClient(nil)
	lgn, err := login1.New()
	if err != nil {
		fmt.Fprintln(os.Stderr, "Cannot read machine-id")
		return 1
	}

	mID := machineid.MachineID("/")
	if mID == "" {
		fmt.Fprintln(os.Stderr, "Cannot read machine-id")
		return 1
	}

	l := lock.New(mID, elc)

	err = l.Lock()
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error locking:", err)
		return 1
	}

	lgn.Reboot(false)

	// TODO(philips): Unlock if the reboot fails.

	return 0
}
Пример #2
0
// NewDBusHandler initializes a new DBusHandler.
func NewDBusHandler(lis *Lis) (*DBusHandler, error) {
	l, err := login1.New()
	if err != nil {
		return nil, err
	}

	return &DBusHandler{
		login1:  l,
		closeCh: make(chan struct{}, 1),
		lis:     lis,
	}, nil

}