mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
run corrosion in Docker as uncloud user, bind mount data dir
This commit is contained in:
1 parent
871fd8c035
commit
c3d3a4242e
4 files changed
+80
-48
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
"net/netip"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"uncloud/internal/fs"
|
||||
)
|
||||
|
||||
@@ -57,3 +58,23 @@ func (c *Config) Write(path, owner string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func MkDataDir(dir, owner string) error {
|
||||
parent, _ := filepath.Split(dir)
|
||||
// Use 0711 for parent directories to allow `owner` to access its nested data directory.
|
||||
if err := os.MkdirAll(parent, 0711); err != nil {
|
||||
return fmt.Errorf("create directory %q: %w", parent, err)
|
||||
}
|
||||
if err := os.Mkdir(dir, 0700); err != nil {
|
||||
if !os.IsExist(err) {
|
||||
return fmt.Errorf("create directory %q: %w", dir, err)
|
||||
}
|
||||
}
|
||||
|
||||
if owner != "" {
|
||||
if err := fs.Chown(dir, owner); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user