mirror of
https://github.com/rancher/os.git
synced 2025-08-13 20:36:36 +00:00
Add docker Bash completion for other consoles
This commit is contained in:
parent
8cdf21d03a
commit
4d834140d0
@ -144,6 +144,12 @@ func consoleInitFunc() error {
|
||||
{"/usr/share/ros/os-release", "/etc/os-release"},
|
||||
}
|
||||
|
||||
if _, err := os.Stat(dockerCompletionFile); err == nil {
|
||||
baseSymlink = append(baseSymlink, symlink{
|
||||
dockerCompletionFile, dockerCompletionLinkFile,
|
||||
})
|
||||
}
|
||||
|
||||
if cfg.Rancher.Console == "default" {
|
||||
// add iptables symlinks for default console
|
||||
baseSymlink = append(baseSymlink, []symlink{
|
||||
|
@ -19,6 +19,8 @@ const (
|
||||
dockerConf = "/var/lib/rancher/conf/docker"
|
||||
dockerDone = "/run/docker-done"
|
||||
dockerLog = "/var/log/docker.log"
|
||||
dockerCompletionLinkFile = "/usr/share/bash-completion/completions/docker"
|
||||
dockerCompletionFile = "/var/lib/rancher/engine/completion"
|
||||
)
|
||||
|
||||
func dockerInitAction(c *cli.Context) error {
|
||||
@ -30,6 +32,12 @@ func dockerInitAction(c *cli.Context) error {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(dockerCompletionFile); err != nil {
|
||||
if _, err := os.Readlink(dockerCompletionLinkFile); err == nil {
|
||||
syscall.Unlink(dockerCompletionLinkFile)
|
||||
}
|
||||
}
|
||||
|
||||
dockerBin := ""
|
||||
dockerPaths := []string{
|
||||
"/usr/bin",
|
||||
|
@ -26,6 +26,7 @@ const (
|
||||
dockerPidFile = "/var/run/docker.pid"
|
||||
sourceDirectory = "/engine"
|
||||
destDirectory = "/var/lib/rancher/engine"
|
||||
dockerCompletionFName = "completion"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -94,10 +95,16 @@ func copyBinaries(source, dest string) error {
|
||||
if err = out.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if file.Name() == dockerCompletionFName {
|
||||
if err := os.Chmod(destFile, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := os.Chmod(destFile, 0751); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user