1
0
mirror of https://github.com/rancher/os.git synced 2025-09-07 01:31:06 +00:00

reboot --kexec almost works

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-07-05 14:14:22 +10:00
parent 5e4b5975a9
commit c5d4cb91c3
6 changed files with 356 additions and 204 deletions

View File

@@ -1,9 +1,13 @@
package install
import (
"bufio"
"bytes"
"html/template"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/rancher/os/log"
)
@@ -43,3 +47,48 @@ DEFAULT RancherOS-current
}
return nil
}
func ReadGlobalCfg(globalCfg string) (string, error) {
append := ""
buf, err := ioutil.ReadFile(globalCfg)
if err != nil {
return append, err
}
s := bufio.NewScanner(bytes.NewReader(buf))
for s.Scan() {
line := strings.TrimSpace(s.Text())
if strings.HasPrefix(line, "APPEND") {
append = strings.TrimSpace(strings.TrimPrefix(line, "APPEND"))
}
}
return append, nil
}
func ReadSyslinuxCfg(currentCfg string) (string, string, error) {
vmlinuzFile := ""
initrdFile := ""
// Need to parse currentCfg for the lines:
// KERNEL ../vmlinuz-4.9.18-rancher^M
// INITRD ../initrd-41e02e6-dirty^M
buf, err := ioutil.ReadFile(currentCfg)
if err != nil {
return vmlinuzFile, initrdFile, err
}
DIST := filepath.Dir(currentCfg)
s := bufio.NewScanner(bytes.NewReader(buf))
for s.Scan() {
line := strings.TrimSpace(s.Text())
if strings.HasPrefix(line, "KERNEL") {
vmlinuzFile = strings.TrimSpace(strings.TrimPrefix(line, "KERNEL"))
vmlinuzFile = filepath.Join(DIST, filepath.Base(vmlinuzFile))
}
if strings.HasPrefix(line, "INITRD") {
initrdFile = strings.TrimSpace(strings.TrimPrefix(line, "INITRD"))
initrdFile = filepath.Join(DIST, filepath.Base(initrdFile))
}
}
return vmlinuzFile, initrdFile, err
}