-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathx_install.sh.bak
200 lines (147 loc) · 3.28 KB
/
x_install.sh.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
################## step 1
# connect to internet
function connect2network() {
echo "please connect to netowrk"
nmtui
}
function configArchRepoMirror() {
echo "Server = https://mirrors.ustc.edu.cn/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
pacman -Syy
}
# sync time
function syncTimedate() {
timedatectl set-ntp true
}
# create disk partition
function createDiskPartition() {
lsblk
fdisk /dev/sda # g --> create a new GPT disklabel n +512M n +16G n default w
}
# format disk
function formatAndMountDisk() {
mkfs.ext4 /dev/sda3
mkswap /dev/sda2
swapon /dev/sda2
mount /dev/sda3 /mnt
# boot partition
# mkfs.fat -F32 /dev/sda1
# mkdir /boot/efi
# mount /dev/sda1 /boot/efi
}
# install base
function createLinuxBase() {
pacstrap /mnt base linux linux-firmware vim openssh
}
# gen fs table
function genfsTable() {
genfstab -U /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab
}
# change env from iso to -> installation
function changeToInstalledArch() {
arch-chroot /mnt
}
################# step 2
# config time zone
function setTimezone() {
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
}
# locale settings
function setLocale() {
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/^#zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
}
# hostname settings
function setHost() {
echo alpha > /etc/hostname
echo '127.0.0.1 localhost
::1 localhost
127.0.0.1 alpha' > /etc/hosts
}
# change root password
function changeRootPwd() {
passwd
}
# install bootLoader
function installBootLoader() {
pacman -S grub efibootmgr networkmanager network-manager-applet mtools dosfstools openssh git base-devel linux-headers os-prober
}
# install grub
function installGrub() {
mkfs.fat -F32 /dev/sda1
mkdir /boot/efi
mount /dev/sda1 /boot/efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
}
# gen grub configuration file
function genGrubCfg() {
grub-mkconfig -o /boot/grub/grub.cfg
}
# basic setup
function basicSetup() {
systemctl enable NetworkManager
useradd -mG wheel akatsuki
passwd akatsuki
EDITOR=vim visudo # %wheel ALL=(ALL) ALL
}
# last step
# exit && umount -a && reboot
######################### step 3
# connect to network
# install xmonad
function installXmonad() {
pacman -S xorg lightdm lightdm-gtk-greeter xmonad xmonad-contrib xmobar dmenu picom nitrogen chromium xterm
systemctl enable lightdm
# vim .xprofile
}
function installXmonad2() {
mkdir .xmonad
cd .xmonad
touch xmonad.hs
vim xmonad.hs
#
}
function main() {
if [ $1 == "conn" ]
then
connect2network
elif [ $1 == "createDiskPartition" ]
then
createDiskPartition
elif [ $1 == "formatAndMountDisk" ]
then
formatAndMountDisk
elif [ $1 == "step1" ]
then
configArchRepoMirror
syncTimedate
createLinuxBase
genfsTable
changeToInstalledArch
elif [ $1 == "step2" ]
then
setTimezone
setLocale
setHost
installBootLoader
installGrub
genGrubCfg
# changeRootPwd
# basicSetup
# exit && umount -a && reboot
elif [ $1 == "userSetup" ]
then
changeRootPwd
basicSetup
elif [ $1 == "archRepoMirror" ]
then
configArchRepoMirror
elif [ $1 == "step3" ]
then
installXmonad
fi
}
main $1