Fix owner issue
This commit is contained in:
parent
617f818df4
commit
4a4da2c080
@ -15,6 +15,7 @@ import (
|
||||
|
||||
// username in the containers under which all containers run
|
||||
const appUsername = "app"
|
||||
const owner = "app:app"
|
||||
const passwordFile = "/srv/.rosti"
|
||||
const deployKeyType = "ed25519"
|
||||
const deployKeyPrefix = "rosti_deploy"
|
||||
@ -328,7 +329,14 @@ func (c *Container) GetHostKey() (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)
|
||||
directory := path.Dir(filename)
|
||||
|
||||
_, err := driver.Exec(c.App.Name, []string{"mkdir", "-p", directory}, "", []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = driver.Exec(c.App.Name, []string{"tee", "-a", filename}, text, []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -338,6 +346,16 @@ func (c *Container) AppendFile(filename string, text string, mode string) error
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", owner, directory}, "", []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", owner, filename}, "", []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -381,12 +399,12 @@ func (c *Container) SetFileContent(filename string, text string, mode string) er
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", "app:app", directory}, "", []string{}, false)
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", owner, directory}, "", []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", "app:app", filename}, "", []string{}, false)
|
||||
_, err = driver.Exec(c.App.Name, []string{"chown", owner, filename}, "", []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ func (p *Processor) UpdateKeys(keys string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = container.SetFileContent(sshPubKeysLocation, keys+"\n", "0600")
|
||||
err = container.AppendFile(sshPubKeysLocation, keys+"\n", "0600")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user