Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount a custom home partition #353

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/mount-sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func mountBindMounts(dryRun bool) error {
}

binds := []bindMount{
{"/var/home", "/home", 0},
{"/var/opt", "/opt", 0},
{"/.system/usr", "/.system/usr", syscall.MS_RDONLY},
}
Expand Down
21 changes: 21 additions & 0 deletions core/integrity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
type IntegrityCheck struct {
rootPath string
systemPath string
varPath string
homeLink string
standardLinks []string
rootPaths []string
etcPaths []string
Expand All @@ -41,6 +43,8 @@ func NewIntegrityCheck(root ABRootPartition, repair bool) (*IntegrityCheck, erro
ic := &IntegrityCheck{
rootPath: root.Partition.MountPoint,
systemPath: systemPath,
varPath: "/var",
homeLink: "/home",
standardLinks: []string{
"/bin",
"/etc",
Expand Down Expand Up @@ -88,6 +92,7 @@ func (ic *IntegrityCheck) check(repair bool) error {
PrintVerboseInfo("IntegrityCheck.check", "Running...")
repairPaths := []string{}
repairLinks := []string{}
repairHomeLink := false

// check if system dir exists
if !fileExists(ic.systemPath) {
Expand All @@ -97,11 +102,18 @@ func (ic *IntegrityCheck) check(repair bool) error {
// check if standard links exist and are links
for _, link := range ic.standardLinks {
testPath := filepath.Join(ic.rootPath, link)
fmt.Println("This is a link: " + link)
if !isLink(testPath) {
fmt.Println("This is not a link:" + link)
repairLinks = append(repairLinks, link)
}
}

// check if home link exists and is a link
if !isLink(ic.homeLink) {
repairHomeLink = true
}

// check if root paths exist
for _, path := range ic.rootPaths {
finalPath := filepath.Join(ic.rootPath, path)
Expand All @@ -127,6 +139,15 @@ func (ic *IntegrityCheck) check(repair bool) error {
}
}

if repairHomeLink {
srcPath := filepath.Join(ic.varPath, "/home")
PrintVerboseInfo("IntegrityCheck", "Repairing link", srcPath, "->", ic.homeLink)
err := os.Symlink(srcPath, ic.homeLink)
if err != nil {
PrintVerboseErr("IntegrityCheck", 2, err)
}
}

for _, link := range repairLinks {
srcPath := filepath.Join(ic.systemPath, link)
dstPath := filepath.Join(ic.rootPath, link)
Expand Down