mirror of
https://github.com/rwinkhart/cachyos-postinstall-helper.git
synced 2026-08-27 20:36:32 -04:00
Add option to use after booting system
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/rwinkhart/go-boilerplate/other"
|
"github.com/rwinkhart/go-boilerplate/other"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mountPoint = "/mnt/cph"
|
var mountPoint = "/mnt/cph"
|
||||||
|
|
||||||
var username string
|
var username string
|
||||||
var partitionR, partitionB string
|
var partitionR, partitionB string
|
||||||
@@ -23,9 +23,13 @@ func main() {
|
|||||||
other.PrintError("This utility must be run as root", 1)
|
other.PrintError("This utility must be run as root", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
partitionR = front.Input("Target root partition (/dev/driveparition):")
|
partitionR = front.Input("Target root partition (/dev/driveparition OR \"/\" if already booted):")
|
||||||
partitionB = front.Input("Target boot (efi) partition (/dev/driveparition):")
|
if partitionR != "/" {
|
||||||
mkdir("/mnt/cph")
|
partitionB = front.Input("Target boot (efi) partition (/dev/driveparition):")
|
||||||
|
mkdir("/mnt/cph")
|
||||||
|
} else {
|
||||||
|
mountPoint = ""
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ func getUsername() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func partitionIsMounted() bool {
|
func partitionIsMounted() bool {
|
||||||
|
if partitionR == "/" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
isMounted, err := mnt.Mounted(mountPoint)
|
isMounted, err := mnt.Mounted(mountPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
other.PrintError("Failed to verify whether "+partitionR+" is mounted", 1)
|
other.PrintError("Failed to verify whether "+partitionR+" is mounted", 1)
|
||||||
@@ -49,6 +53,10 @@ func partitionIsMounted() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mountPartition() {
|
func mountPartition() {
|
||||||
|
if partitionR == "/" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !partitionIsMounted() {
|
if !partitionIsMounted() {
|
||||||
// root
|
// root
|
||||||
cmd := exec.Command("mount", partitionR, mountPoint)
|
cmd := exec.Command("mount", partitionR, mountPoint)
|
||||||
|
|||||||
Reference in New Issue
Block a user