mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
run corrosion in Docker as uncloud user, bind mount data dir
This commit is contained in:
@@ -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