1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 14:23:11 +00:00

Make docker-compose command available on console

This commit is contained in:
Olli Janatuinen
2020-11-30 21:18:58 +02:00
parent c25bb67fd2
commit 2c8a40b547
3 changed files with 25 additions and 0 deletions

View File

@@ -169,6 +169,24 @@ func consoleInitFunc() error {
}
*/
// create placeholder for docker-compose binary
const ComposePlaceholder = `
#!/bin/bash
echo 'INFO: System service "docker-compose" is not yet enabled'
sudo ros service enable docker-compose
sudo ros service up docker-compose
`
if _, err := os.Stat("/var/lib/rancher/compose"); os.IsNotExist(err) {
if err := os.MkdirAll("/var/lib/rancher/compose", 0555); err != nil {
log.Error(err)
}
}
if _, err := os.Stat("/var/lib/rancher/compose/docker-compose"); os.IsNotExist(err) {
if err := ioutil.WriteFile("/var/lib/rancher/compose/docker-compose", []byte(ComposePlaceholder), 0755); err != nil {
log.Error(err)
}
}
for _, link := range baseSymlink {
syscall.Unlink(link.newname)
if err := os.Symlink(link.oldname, link.newname); err != nil {

View File

@@ -27,6 +27,7 @@ const (
sourceDirectory = "/engine"
destDirectory = "/var/lib/rancher/engine"
dockerCompletionFName = "completion"
dockerComposeFName = "docker-compose"
)
var (
@@ -99,6 +100,10 @@ func copyBinaries(source, dest string) error {
if err := os.Chmod(destFile, 0644); err != nil {
return err
}
} else if file.Name() == dockerComposeFName {
if err := os.Chmod(destFile, 0755); err != nil {
return err
}
} else {
if err := os.Chmod(destFile, 0751); err != nil {
return err

View File

@@ -54,6 +54,8 @@ func symLinkEngineBinary() []symlink {
{"/var/lib/rancher/engine/docker-containerd-ctr", "/usr/bin/docker-containerd-ctr"},
{"/var/lib/rancher/engine/docker-containerd-shim", "/usr/bin/docker-containerd-shim"},
{"/var/lib/rancher/engine/docker-runc", "/usr/bin/docker-runc"},
{"/var/lib/rancher/compose/docker-compose", "/usr/bin/docker-compose"},
}
return baseSymlink
}