Skip to content

Commit

Permalink
change owner of folder to current user after creating zfs dataset (close
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Mar 25, 2019
1 parent 7a4a8ad commit a58e6d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions worker/zfs_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package worker
import (
"fmt"
"os"
"os/user"
"strings"

"github.com/codeskyblue/go-sh"
Expand Down Expand Up @@ -40,6 +41,14 @@ func (z *zfsHook) preJob() error {
if err := sh.Command("sudo", "zfs", "set", "mountpoint="+workingDir, zfsDataset).Run(); err != nil {
return err
}
usr, err := user.Current()
if err != nil {
return err
}
logger.Infof("Chown %s to %s(%s)", workingDir, usr.Uid, usr.Username)
if err := sh.Command("sudo", "chown", usr.Uid, workingDir).Run(); err != nil {
return err
}
}
return nil
}

0 comments on commit a58e6d3

Please sign in to comment.