mirror of
https://github.com/rwinkhart/cachyos-postinstall-helper.git
synced 2026-08-27 20:36:32 -04:00
Fourth round of fixes
This commit is contained in:
+1
-7
@@ -1,10 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/front"
|
||||
"github.com/rwinkhart/go-boilerplate/other"
|
||||
)
|
||||
|
||||
func configurations() {
|
||||
@@ -40,10 +37,7 @@ func configurations() {
|
||||
}
|
||||
fallthrough
|
||||
case 6:
|
||||
err := os.MkdirAll(mountPoint+"/home/"+getUsername()+"/.config/zed", 0755)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to create zed config directory", 1)
|
||||
}
|
||||
mkdir(mountPoint + "/home/" + getUsername() + "/.config/zed")
|
||||
writeFile(mountPoint+"/home/"+getUsername()+"/.config/zed/settings.json", zed, getUsername(), 0600)
|
||||
|
||||
if !doAll {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func cosmic() {
|
||||
version := "/v1/"
|
||||
filenamesToValues := map[string]string{
|
||||
@@ -21,8 +25,11 @@ func cosmic() {
|
||||
"Panel.Panel" + version + "size": "XS",
|
||||
"Tk" + version + "show_maximize": "false"}
|
||||
|
||||
mkdir(mountPoint + "/home/" + getUsername() + "/.config/cosmic")
|
||||
for key, value := range filenamesToValues {
|
||||
writeFile(mountPoint+"/home/"+getUsername()+"/.config/cosmic/com.system76.Cosmic"+key, value+"\n", getUsername(), 0755)
|
||||
filePath := mountPoint + "/home/" + getUsername() + "/.config/cosmic/com.system76.Cosmic" + key
|
||||
mkdir(filePath[:strings.LastIndex(filePath, "/")])
|
||||
writeFile(filePath, value+"\n", getUsername(), 0755)
|
||||
}
|
||||
|
||||
// Replace SDDM with cosmic-greeter
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/front"
|
||||
@@ -26,10 +25,7 @@ func main() {
|
||||
|
||||
partitionR = front.Input("Target root partition (/dev/driveparition):")
|
||||
partitionB = front.Input("Target boot (efi) partition (/dev/driveparition):")
|
||||
err = os.MkdirAll("/mnt/cph", 0777)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to create mount directory (/mnt/cph)", 1)
|
||||
}
|
||||
mkdir("/mnt/cph")
|
||||
|
||||
for {
|
||||
fmt.Println()
|
||||
@@ -37,7 +33,7 @@ func main() {
|
||||
switch choice {
|
||||
case 1:
|
||||
if partitionIsMounted() {
|
||||
fmt.Println(partitionR + " is already mounted on " + mountPoint)
|
||||
fmt.Println("\n" + partitionR + " is already mounted on " + mountPoint)
|
||||
} else {
|
||||
premount()
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func system() {
|
||||
writeFile(mountPoint+"/etc/doas.conf", "permit persist keepenv :wheel as root\n", "root", 0644)
|
||||
managePackage("-S", "opendoas")
|
||||
chrootCommandRun([]string{"pacman", "-S", "--asexplicit", "--dbonly", "archlinux-keyring", "autoconf", "automake", "binutils", "bison", "debugedit", "fakeroot", "file", "findutils", "flex", "gawk", "gcc", "gettext", "grep", "groff", "gzip", "libtool", "m4", "make", "pacman", "patch", "pkgconf", "sed", "texinfo", "which", "--noconfirm"})
|
||||
chrootCommandRun([]string{"pacman", "-R", "sudo", "qt-sudo", "--noconfirm"})
|
||||
chrootCommandRun([]string{"pacman", "-R", "base-devel", "sudo", "--noconfirm"})
|
||||
|
||||
if !doAll {
|
||||
break
|
||||
@@ -66,7 +66,7 @@ func system() {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case 9:
|
||||
case 8:
|
||||
addKernelParams([]string{"amd_pstate=passive"})
|
||||
}
|
||||
}
|
||||
|
||||
+1
-12
@@ -1,11 +1,5 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/other"
|
||||
)
|
||||
|
||||
func universalTweaks() {
|
||||
// Lock root account
|
||||
chrootCommandRun([]string{"passwd", "--delete", "root"})
|
||||
@@ -15,10 +9,5 @@ func universalTweaks() {
|
||||
chrootCommandRun([]string{"usermod", "-aG", "uucp", getUsername()})
|
||||
|
||||
// Force disable kernel watchdog (kernel parameters should do this as well)
|
||||
f, err := os.Create(mountPoint + "/etc/modprobe.d/blacklist.conf")
|
||||
if err != nil {
|
||||
other.PrintError("Failed to create "+mountPoint+"/etc/modprobe.d/blacklist.conf", 1)
|
||||
}
|
||||
f.WriteString("# Disable kernel watchdog\nblacklist iTCO_wdt")
|
||||
f.Close()
|
||||
writeFile(mountPoint+"/etc/modprobe.d/blacklist.conf", "# Disable kernel watchdog\nblacklist iTCO_wdt\n", "root", 0644)
|
||||
}
|
||||
|
||||
+12
-16
@@ -3,8 +3,6 @@ package main
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
mnt "github.com/moby/sys/mountinfo"
|
||||
@@ -27,8 +25,7 @@ func writeFile(path, data, owner string, perms os.FileMode) {
|
||||
other.PrintError("Failed to write to "+path+":"+err.Error(), 1)
|
||||
}
|
||||
if owner != "root" {
|
||||
uid := getUID()
|
||||
err = os.Chown(path, uid, uid)
|
||||
err = os.Chown(path, 1000, 1000)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to set ownership of "+path, 1)
|
||||
}
|
||||
@@ -43,18 +40,6 @@ func getUsername() string {
|
||||
return localUsername
|
||||
}
|
||||
|
||||
func getUID() int {
|
||||
userInfo, err := user.Lookup(getUsername())
|
||||
if err != nil {
|
||||
other.PrintError("Failed to lookup UID for "+getUsername(), 1)
|
||||
}
|
||||
uid, err := strconv.Atoi(userInfo.Uid)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to convert UID to integer", 1)
|
||||
}
|
||||
return uid
|
||||
}
|
||||
|
||||
func partitionIsMounted() bool {
|
||||
isMounted, err := mnt.Mounted(mountPoint)
|
||||
if err != nil {
|
||||
@@ -89,3 +74,14 @@ func chrootCommandRun(args []string) {
|
||||
other.PrintError("Failed to run \""+strings.Join(args[1:], " ")+"\" within chroot: "+err.Error(), 1)
|
||||
}
|
||||
}
|
||||
|
||||
func mkdir(path string) {
|
||||
err := os.MkdirAll(path, 0755)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to create \""+path+"/\" directory", 1)
|
||||
}
|
||||
err = os.Chown(path, 1000, 1000)
|
||||
if err != nil {
|
||||
other.PrintError("Failed to set ownership of \""+path+"\"", 1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user