This commit is contained in:
parent
bcc641307a
commit
036aa4fc28
3 changed files with 9 additions and 6 deletions
|
@ -242,17 +242,17 @@ func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
|||
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 {
|
||||
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 {
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ func (c *Container) GetHostKey() (string, error) {
|
|||
}
|
||||
|
||||
// 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()
|
||||
|
||||
_, 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 {
|
||||
err = container.AppendOfFile(sshPubKeysLocation, pubKey+"\n", "0600")
|
||||
err = container.AppendFile(sshPubKeysLocation, pubKey+"\n", "0600")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
|
@ -419,7 +419,10 @@ func getDeploySSHKeysEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||
|
||||
// Assembling reply message
|
||||
reply := ReplyMessage{
|
||||
Payload: struct{ PrivateKey, PublicKey string }{
|
||||
Payload: struct {
|
||||
PrivateKey string `json:"private_key"`
|
||||
PublicKey string `json:"public_key"`
|
||||
}{
|
||||
PrivateKey: privateKey,
|
||||
PublicKey: pubKey,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue