forked from TrenchBoot/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_linux.go
38 lines (33 loc) · 1.01 KB
/
init_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2018 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"log"
"strconv"
"syscall"
"github.com/u-root/u-root/pkg/cmdline"
)
func init() {
osInitGo = runOSInitGo
}
func runOSInitGo() {
// systemd is "special". If we are supposed to run systemd, we're
// going to exec, and if we're going to exec, we're done here.
// systemd uber alles.
initFlags := cmdline.GetInitFlagMap()
// systemd gets upset when it discovers it isn't really process 1, so
// we can't start it in its own namespace. I just love systemd.
systemd, present := initFlags["systemd"]
systemdEnabled, boolErr := strconv.ParseBool(systemd)
if present && boolErr == nil && systemdEnabled == true {
v := cmdList[0]
debug("Exec %v", v)
if err := syscall.Exec(v, []string{v}, envs); err != nil {
log.Printf("Lucky you, systemd failed: %v", err)
}
// well, what a shame.
cmdList = cmdList[1:]
cmdCount++
}
}