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