mirror of
https://github.com/rwinkhart/cachyos-postinstall-helper.git
synced 2026-09-05 16:47:32 -04:00
Fourth round of fixes
This commit is contained in:
+1
-7
@@ -1,10 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
"github.com/rwinkhart/go-boilerplate/other"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func configurations() {
|
func configurations() {
|
||||||
@@ -40,10 +37,7 @@ func configurations() {
|
|||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
case 6:
|
case 6:
|
||||||
err := os.MkdirAll(mountPoint+"/home/"+getUsername()+"/.config/zed", 0755)
|
mkdir(mountPoint + "/home/" + getUsername() + "/.config/zed")
|
||||||
if err != nil {
|
|
||||||
other.PrintError("Failed to create zed config directory", 1)
|
|
||||||
}
|
|
||||||
writeFile(mountPoint+"/home/"+getUsername()+"/.config/zed/settings.json", zed, getUsername(), 0600)
|
writeFile(mountPoint+"/home/"+getUsername()+"/.config/zed/settings.json", zed, getUsername(), 0600)
|
||||||
|
|
||||||
if !doAll {
|
if !doAll {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func cosmic() {
|
func cosmic() {
|
||||||
version := "/v1/"
|
version := "/v1/"
|
||||||
filenamesToValues := map[string]string{
|
filenamesToValues := map[string]string{
|
||||||
@@ -21,8 +25,11 @@ func cosmic() {
|
|||||||
"Panel.Panel" + version + "size": "XS",
|
"Panel.Panel" + version + "size": "XS",
|
||||||
"Tk" + version + "show_maximize": "false"}
|
"Tk" + version + "show_maximize": "false"}
|
||||||
|
|
||||||
|
mkdir(mountPoint + "/home/" + getUsername() + "/.config/cosmic")
|
||||||
for key, value := range filenamesToValues {
|
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
|
// Replace SDDM with cosmic-greeter
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"os/user"
|
"os/user"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
@@ -26,10 +25,7 @@ func main() {
|
|||||||
|
|
||||||
partitionR = front.Input("Target root partition (/dev/driveparition):")
|
partitionR = front.Input("Target root partition (/dev/driveparition):")
|
||||||
partitionB = front.Input("Target boot (efi) partition (/dev/driveparition):")
|
partitionB = front.Input("Target boot (efi) partition (/dev/driveparition):")
|
||||||
err = os.MkdirAll("/mnt/cph", 0777)
|
mkdir("/mnt/cph")
|
||||||
if err != nil {
|
|
||||||
other.PrintError("Failed to create mount directory (/mnt/cph)", 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
@@ -37,7 +33,7 @@ func main() {
|
|||||||
switch choice {
|
switch choice {
|
||||||
case 1:
|
case 1:
|
||||||
if partitionIsMounted() {
|
if partitionIsMounted() {
|
||||||
fmt.Println(partitionR + " is already mounted on " + mountPoint)
|
fmt.Println("\n" + partitionR + " is already mounted on " + mountPoint)
|
||||||
} else {
|
} else {
|
||||||
premount()
|
premount()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func system() {
|
|||||||
writeFile(mountPoint+"/etc/doas.conf", "permit persist keepenv :wheel as root\n", "root", 0644)
|
writeFile(mountPoint+"/etc/doas.conf", "permit persist keepenv :wheel as root\n", "root", 0644)
|
||||||
managePackage("-S", "opendoas")
|
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", "-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 {
|
if !doAll {
|
||||||
break
|
break
|
||||||
@@ -66,7 +66,7 @@ func system() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
case 9:
|
case 8:
|
||||||
addKernelParams([]string{"amd_pstate=passive"})
|
addKernelParams([]string{"amd_pstate=passive"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-12
@@ -1,11 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/other"
|
|
||||||
)
|
|
||||||
|
|
||||||
func universalTweaks() {
|
func universalTweaks() {
|
||||||
// Lock root account
|
// Lock root account
|
||||||
chrootCommandRun([]string{"passwd", "--delete", "root"})
|
chrootCommandRun([]string{"passwd", "--delete", "root"})
|
||||||
@@ -15,10 +9,5 @@ func universalTweaks() {
|
|||||||
chrootCommandRun([]string{"usermod", "-aG", "uucp", getUsername()})
|
chrootCommandRun([]string{"usermod", "-aG", "uucp", getUsername()})
|
||||||
|
|
||||||
// Force disable kernel watchdog (kernel parameters should do this as well)
|
// Force disable kernel watchdog (kernel parameters should do this as well)
|
||||||
f, err := os.Create(mountPoint + "/etc/modprobe.d/blacklist.conf")
|
writeFile(mountPoint+"/etc/modprobe.d/blacklist.conf", "# Disable kernel watchdog\nblacklist iTCO_wdt\n", "root", 0644)
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-16
@@ -3,8 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mnt "github.com/moby/sys/mountinfo"
|
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)
|
other.PrintError("Failed to write to "+path+":"+err.Error(), 1)
|
||||||
}
|
}
|
||||||
if owner != "root" {
|
if owner != "root" {
|
||||||
uid := getUID()
|
err = os.Chown(path, 1000, 1000)
|
||||||
err = os.Chown(path, uid, uid)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
other.PrintError("Failed to set ownership of "+path, 1)
|
other.PrintError("Failed to set ownership of "+path, 1)
|
||||||
}
|
}
|
||||||
@@ -43,18 +40,6 @@ func getUsername() string {
|
|||||||
return localUsername
|
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 {
|
func partitionIsMounted() bool {
|
||||||
isMounted, err := mnt.Mounted(mountPoint)
|
isMounted, err := mnt.Mounted(mountPoint)
|
||||||
if err != nil {
|
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)
|
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