1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +00:00

Need to remove the immutable bit from ldlinux.sys so root can remove it

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-03-31 12:15:15 +00:00
parent e871741ec3
commit 62d8aaa58e
2 changed files with 17 additions and 4 deletions

View File

@@ -841,9 +841,21 @@ func upgradeBootloader(device, baseName, bootDir, diskType string) error {
return err
}
backupSyslinuxDir := filepath.Join(baseName, bootDir+"syslinux_backup")
if err := os.RemoveAll(backupSyslinuxDir); err != nil {
log.Errorf("RemoveAll (%s): %s", backupSyslinuxDir, err)
return err
if _, err := os.Stat(backupSyslinuxDir); !os.IsNotExist(err) {
backupSyslinuxLdlinuxSys := filepath.Join(backupSyslinuxDir, "ldlinux.sys")
if _, err := os.Stat(backupSyslinuxLdlinuxSys); !os.IsNotExist(err) {
//need a privileged container that can chattr -i ldlinux.sys
cmd := exec.Command("chattr", "-i", backupSyslinuxLdlinuxSys)
if err := cmd.Run(); err != nil {
log.Errorf("%s", err)
return err
}
}
if err := os.RemoveAll(backupSyslinuxDir); err != nil {
log.Errorf("RemoveAll (%s): %s", backupSyslinuxDir, err)
return err
}
}
if err := os.Rename(grubDir, grubBackup); err != nil {