Skip to content

Commit d15c566

Browse files
committed
Improve everything and add passwd functionality
1 parent 1e4ad71 commit d15c566

5 files changed

Lines changed: 251 additions & 97 deletions

File tree

data/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type yamlfile struct {
4646
Format bool `yaml:"format"`
4747
} `yaml:"swap"`
4848
} `yaml:"partitions"`
49+
Password string `yaml:"passwd"`
4950
GrubInstallDisk string `yaml:"grub_install_disk"`
5051
PacstrapSkip bool `yaml:"pacstrap_skip"`
5152
AdditionalPackages string `yaml:"additional_packages"`

go.mod

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
module github.com/Tom5521/ArchLinuxInstaller
22

3-
go 1.21.0
3+
go 1.21
4+
5+
toolchain go1.21.3
6+
7+
require (
8+
github.com/Tom5521/CmdRunTools v1.2.2
9+
github.com/Tom5521/MyGolangTools v0.0.0-20230816231450-36b02638e41c
10+
github.com/gookit/color v1.5.4
11+
gopkg.in/yaml.v3 v3.0.1
12+
)
413

514
require (
6-
github.com/Tom5521/MyGolangTools v0.0.0-20230816231450-36b02638e41c // indirect
7-
github.com/gookit/color v1.5.4 // indirect
815
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
916
golang.org/x/sys v0.10.0 // indirect
10-
gopkg.in/yaml.v3 v3.0.1 // indirect
1117
)

go.sum

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
github.com/Tom5521/MyGolangTools v0.0.0-20230806053540-1d169699a019 h1:SNXIavRN8EMNEZb8LVOFEZl1pgvPALH5UIHrlOBM8Qw=
2-
github.com/Tom5521/MyGolangTools v0.0.0-20230806053540-1d169699a019/go.mod h1:QovXEupbIBTOVIJ97GiRFabS4UJQm+Me4n3D2rkf6vg=
1+
github.com/Tom5521/CmdRunTools v1.2.2 h1:cAcJRBLs1vAYkV2kN1+6rEnT/889NonI0IBk1u2JFWU=
2+
github.com/Tom5521/CmdRunTools v1.2.2/go.mod h1:/OX3Rx+2i6E0UIYSV2xUrk0uENnQAg6gTXSC9ZpGtz4=
33
github.com/Tom5521/MyGolangTools v0.0.0-20230816231450-36b02638e41c h1:chvCOXnVMqlAmhYmr3/+W/rjIrP+rjS2YS05b7pXM30=
44
github.com/Tom5521/MyGolangTools v0.0.0-20230816231450-36b02638e41c/go.mod h1:QovXEupbIBTOVIJ97GiRFabS4UJQm+Me4n3D2rkf6vg=
5+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
57
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
68
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
9+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
10+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
12+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
713
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
814
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
915
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
1016
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1118
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1219
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1320
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 90 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,106 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/Tom5521/ArchLinuxInstaller/data"
78
"github.com/Tom5521/ArchLinuxInstaller/src"
89
"github.com/Tom5521/MyGolangTools/commands"
9-
"github.com/gookit/color"
1010
)
1111

1212
var sh = commands.Sh{}
1313

14+
var HelpStr = `
15+
Usage:
16+
#[bin] [argument] -[option]
17+
18+
Arguments:
19+
- help Print this text
20+
21+
- install Run all the nesesary functions to install completely Arch Linux
22+
23+
- pacstrap Only runs the pacstrap functions
24+
25+
- grub Only installs Grub
26+
27+
- newconfig Creates a new config overwriting the original
28+
29+
- part Open cfdisk to partitionate the install disk
30+
31+
- passwd Only changes the password of the new root
32+
33+
- mount Only mounts the disks in her routes
34+
35+
Options:
36+
Argument options will be applied before the config fil
37+
38+
-nopasswd Skip the passwd set
39+
40+
-nopacstrap Skip the pacstrap prosess
41+
42+
-nopart Skip the partitionating prosess (not open cfdisk)
43+
44+
-nogrub Don't install Grub
45+
46+
-noformat Don't format the partitions
47+
48+
-nomount Don't mount the partitions
49+
50+
-nopacmanconf Don't paste custom pacman config
51+
52+
-nowifi Don't configure for wifi
53+
54+
-nofstab Don't generate a fstab for the new system
55+
56+
-nokeymap Don't config the keymap for the new system
57+
58+
`
59+
60+
func PrintHelp() {
61+
fmt.Print(HelpStr)
62+
}
63+
1464
func main() {
15-
if len(os.Args) > 1 {
16-
if os.Args[1] == "install" {
17-
src.Wifi()
18-
src.PacmanConf()
19-
src.Format()
20-
src.Mount()
21-
src.Pacstrap()
22-
src.Fstab()
23-
src.Grub()
24-
src.Keymap()
25-
src.FinalCmds()
26-
}
27-
if os.Args[1] == "pacstrap" {
28-
src.Wifi()
29-
src.PacmanConf()
30-
src.Mount()
31-
src.Pacstrap()
32-
}
33-
if os.Args[1] == "grub" {
34-
src.Mount()
35-
src.Fstab()
36-
src.Grub()
37-
}
38-
if os.Args[1] == "newconfig" {
39-
data.NewYamlFile()
40-
err := sh.Cmd("vim " + data.Pfilename)
41-
if err != nil {
42-
color.Red.Println("Error oppening vim." + err.Error())
43-
}
65+
if len(os.Args) == 0 {
66+
fmt.Println("Not enough arguments")
67+
return
68+
}
69+
switch os.Args[1] {
70+
case "help":
71+
PrintHelp()
72+
case "passwd":
73+
src.ConfigRootPasswd()
74+
case "part":
75+
src.Partitioning()
76+
case "install":
77+
src.Partitioning()
78+
src.Wifi()
79+
src.PacmanConf()
80+
src.Format()
81+
src.Mount()
82+
src.Pacstrap()
83+
src.Fstab()
84+
src.Grub()
85+
src.Keymap()
86+
src.ConfigRootPasswd()
87+
src.FinalCmds()
88+
case "pacstrap":
89+
src.Wifi()
90+
src.PacmanConf()
91+
src.Mount()
92+
src.Pacstrap()
93+
case "grub":
94+
src.Mount()
95+
src.Fstab()
96+
src.Grub()
97+
case "mount":
98+
src.Mount()
99+
case "newconfig":
100+
data.NewYamlFile()
101+
err := sh.Cmd("vim " + data.Pfilename)
102+
if err != nil {
103+
src.Error("Error oppening vim.\n" + err.Error())
44104
}
45105
}
46106
}

0 commit comments

Comments
 (0)