1
0
mirror of https://github.com/rancher/os.git synced 2025-09-16 15:09:27 +00:00

Use symlinks for power commands instead of bind mounts

This commit is contained in:
Josh Curl
2016-11-17 09:49:27 -08:00
parent 67c7ba0fed
commit 9a34545aa9
2 changed files with 28 additions and 4 deletions

View File

@@ -45,6 +45,8 @@ func entrypointAction(c *cli.Context) error {
writeFiles(cfg)
}
setupPowerOperations()
if len(os.Args) < 3 {
return nil
}
@@ -74,3 +76,29 @@ func writeFiles(cfg *config.CloudConfig) error {
cloudinitexecute.WriteFiles(cfg, info.Name[1:])
return nil
}
func setupPowerOperations() {
for _, powerOperation := range []string{
"/sbin/poweroff",
"/sbin/shutdown",
"/sbin/reboot",
"/sbin/halt",
"/usr/sbin/poweroff",
"/usr/sbin/shutdown",
"/usr/sbin/reboot",
"/usr/sbin/halt",
} {
os.Remove(powerOperation)
}
for _, link := range []symlink{
{config.ROS_BIN, "/sbin/poweroff"},
{config.ROS_BIN, "/sbin/reboot"},
{config.ROS_BIN, "/sbin/halt"},
{config.ROS_BIN, "/sbin/shutdown"},
} {
if err := os.Symlink(link.oldname, link.newname); err != nil {
log.Error(err)
}
}
}