This commit is contained in:
parent
bcc641307a
commit
036aa4fc28
@ -242,17 +242,17 @@ func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := driver.Exec(c.App.Name, []string{"mkdir", "-p", "/srv/.ssh"}, "", []string{}, false)
|
_, err := driver.Exec(c.App.Name, []string{"mkdir", "-p", "/srv/.ssh"}, "", []string{}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = driver.Exec(c.App.Name, []string{"ssh-keygen", "-f", "/srv/.ssh/id_rsa", "-P", ""}, "", []string{}, false)
|
_, err = driver.Exec(c.App.Name, []string{"ssh-keygen", "-f", "/srv/.ssh/id_rsa", "-P", ""}, "", []string{}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = driver.Exec(c.App.Name, []string{"chown", "app:app", "-R", "/srv/.ssh"}, "", []string{}, false)
|
_, err = driver.Exec(c.App.Name, []string{"chown", "app:app", "-R", "/srv/.ssh"}, "", []string{}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ func (c *Container) GetHostKey() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append text to a file in the container
|
// Append text to a file in the container
|
||||||
func (c *Container) AppendOfFile(filename string, text string, mode string) error {
|
func (c *Container) AppendFile(filename string, text string, mode string) error {
|
||||||
driver := c.getDriver()
|
driver := c.getDriver()
|
||||||
|
|
||||||
_, err := driver.Exec(c.App.Name, []string{"tee", "-a", filename}, text, []string{}, false)
|
_, err := driver.Exec(c.App.Name, []string{"tee", "-a", filename}, text, []string{}, false)
|
||||||
|
@ -510,7 +510,7 @@ func (p *Processor) GenerateDeploySSHKeys() (string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if created {
|
if created {
|
||||||
err = container.AppendOfFile(sshPubKeysLocation, pubKey+"\n", "0600")
|
err = container.AppendFile(sshPubKeysLocation, pubKey+"\n", "0600")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,10 @@ func getDeploySSHKeysEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
|
|
||||||
// Assembling reply message
|
// Assembling reply message
|
||||||
reply := ReplyMessage{
|
reply := ReplyMessage{
|
||||||
Payload: struct{ PrivateKey, PublicKey string }{
|
Payload: struct {
|
||||||
|
PrivateKey string `json:"private_key"`
|
||||||
|
PublicKey string `json:"public_key"`
|
||||||
|
}{
|
||||||
PrivateKey: privateKey,
|
PrivateKey: privateKey,
|
||||||
PublicKey: pubKey,
|
PublicKey: pubKey,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user