-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
228 lines (222 loc) · 6.81 KB
/
setup.sh
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
echo "1 - If you have an already installed system, then you can make settings, saving all data from the user's home folder. Select a section?"
echo "2 - Partition disk"
read root
if [[ "$root" == "2" ]]; then
fdisk -l
echo "Select the drive (for example: /dev/sda): "
read hard
cfdisk $hard
fi
fdisk -l
echo "Select (for example: /dev/sda1): "
read root_directory
if [[ "$root" == "2" ]]; then
echo "Format section?"
echo "1 - Yes"
echo "2 - No"
read format_root
if [[ "$format_root" == "1" ]]; then
mkfs.ext4 $root_directory
fi
mount $root_directory /mnt
echo "Mount partition for home folder?"
echo "1 - Yes"
echo "2 - No"
read home
if [[ "$home" == "1" ]]; then
echo "Select (for example: /dev/sda1): "
read home_directory
echo "Format section?"
echo "1 - Yes"
echo "2 - No"
read format_home
if [[ "$format_root" == "1" ]]; then
mkfs.ext4 $home_directory
fi
mkdir /mnt/home
mount $home_directory /mnt/home
fi
elif [[ "$root" == "1" ]]; then
mount $root_directory /mnt
fi
echo "Use a swap partition?"
echo "1 - Yes"
echo "2 - No"
read swap
if [[ "$swap" == "1" ]]; then
echo "Select(for example: /dev/sda1): "
read swap_directory
mkswap $swap_directory
swapon $swap_directory
fi
mkdir /mnt/boot
mkdir /mnt/boot/efi
echo "Select an EFI partition (for example: /dev/sda1): "
read efi
echo "Format section?"
echo "1 - Yes"
echo "2 - No"
read format_efi
if [[ "$format_efi" == "1" ]]; then
mkfs.fat -F32 $efi
fi
mount $efi /mnt/boot/efi
echo "Select the system kernel: "
echo "1 - linux"
echo "2 - linux_lts"
echo "3 - linux_zen"
echo "4 - linux_hardened"
read kernel
if [[ "$root" == "1" ]]; then
ls /mnt| grep -v /mnt/home | xargs rm -rfv
fi
if [[ "$kernel" == "1" ]]; then
pacstrap /mnt base linux linux-firmware networkmanager wget git nano vim efibootmgr sudo sed
elif [[ "$kernel" == "2" ]]; then
pacstrap /mnt base linux-lts linux-firmware networkmanager wget git nano vim efibootmgr sudo sed
elif [[ "$kernel" == "3" ]]; then
pacstrap /mnt base linux-zen linux-firmware networkmanager wget git nano vim efibootmgr sudo sed
elif [[ "$kernel" == "4" ]]; then
pacstrap /mnt base linux-hardened linux-firmware networkmanager wget git nano vim efibootmgr sudo sed
fi
if [[ "$root" == "1" ]]; then
echo '
echo "Enter your region (for example: Europe): "
read reg
echo "Enter your city (for example: Moscow): "
read city
ln -sf /usr/share/zoneinfo/$reg/$city /etc/localtime
hwclock --systohc --utc
echo "Enter the computer name: "
read pc_name
echo "$pc_name" > /etc/hostname
echo "127.0.1.1 localhost.localdomain $pc_name" > /etc/hosts
systemctl enable NetworkManager
echo "What locale do you need (for example: ru_RU.UTF_8 UTF-8): "
read locale
sed "/$locale/s/^#//g" -i /etc/locale.gen
sed "/en_US.UTF-8 UTF_8/s/^#//g" -i /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
usermod -aG wheel -s /bin/bash $user
sed "/%wheel ALL=(ALL) ALL/s/^#//g" -i /etc/sudoers
username - $user
echo "Select the system shell: "
echo "1 - KDE"
echo "2 - GNOME"
echo "3 - XFCE"
echo "4 - Cinnamon"
echo "5 - Mate"
echo "6 - Deepin"
read de
echo "Select video driver: "
echo "1 - Nvdia"
echo "2 - AMD"
read driver
if [[ "$driver" == "1" ]]; then
if [[ "$de" == "1" ]]; then
pacman -Sy plasma dolphin konsole nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$de" == "2" ]]; then
pacman -Sy gnome gnome-extra nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$de" == "3" ]]; then
pacman -Sy xfce4 xfce4-goodies nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$de" == "4" ]]; then
pacman -Sy cinnamon nemo-fileroller nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$de" == "5" ]]; then
pacman -Sy mate mate-extra nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$de" == "6" ]]; then
pacman -Sy deepin deepin-extra nvidia-settings nvidia sddm xorg xorg-xinit
fi
systemctl enable sddm
elif [[ "$driver" == "2" ]]; then
if [[ "$de" == "1" ]]; then
pacman -Sy plasma dolphin konsole mesa sddm xorg xorg-xinit
elif [[ "$de" == "2" ]]; then
pacman -Sy gnome gnome-extra mesa sddm xorg xorg-xinit
elif [[ "$de" == "3" ]]; then
pacman -Sy xfce4 xfce4-goodies mesa sddm xorg xorg-xinit
elif [[ "$de" == "4" ]]; then
pacman -Sy cinnamon nemo-fileroller mesa sddm xorg xorg-xinit
elif [[ "$de" == "5" ]]; then
pacman -Sy mate mate-extra mesa sddm xorg xorg-xinit
elif [[ "$de" == "6" ]]; then
pacman -Sy deepin deepin-extra mesa sddm xorg xorg-xinit
fi
systemctl enable sddm
fi
username - root
pacman -S grub
grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi --removable
grub-mkconfig -o /boot/grub/grub.cfg
echo "Root password"
passwd
' > setup_post.sh
elif [[ "$root" == "2" ]]; then
echo '
echo "Enter your region (for example: Europe): "
read reg
echo "Enter your city (for example: Moscow): "
read city
ln -sf /usr/share/zoneinfo/$reg/$city /etc/localtime
hwclock --systohc --utc
echo "Enter the computer name: "
read pc_name
echo "$pc_name" > /etc/hostname
echo "127.0.1.1 localhost.localdomain $pc_name" > /etc/hosts
systemctl enable NetworkManager
echo "What locale do you need (for example: ru_RU.UTF_8 UTF-8): "
read locale
sed "/$locale/s/^#//g" -i /etc/locale.gen
sed "/en_US.UTF-8 UTF_8/s/^#//g" -i /etc/locale.gen
sed "/%wheel ALL=(ALL) ALL/s/^#//g" -i /etc/sudoers
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "Enter your username: "
read user
useradd -m -g users -G wheel -s /bin/bash $user
passwd $user
username - $user
echo "Select the system shell: "
echo "1 - KDE"
echo "2 - GNOME"
echo "3 - XFCE"
echo "4 - Cinnamon"
echo "5 - Mate"
echo "6 - Deepin"
read de
echo "Select video driver: "
echo "1 - Nvdia"
echo "2 - AMD"
read driver
if [[ "$driver" == "1" ]]; then
pacman -Sy nvidia-settings nvidia sddm xorg xorg-xinit
elif [[ "$driver" == "2" ]]; then
pacman -Sy mesa sddm xorg xorg-xinit
fi
systemctl enable sddm
if [[ "$de" == "1" ]]; then
pacman -Sy plasma dolphin konsole
elif [[ "$de" == "2" ]]; then
pacman -Sy gnome gnome-extra
elif [[ "$de" == "3" ]]; then
pacman -Sy xfce4 xfce4-goodies
elif [[ "$de" == "4" ]]; then
pacman -Sy cinnamon nemo-fileroller
elif [[ "$de" == "5" ]]; then
pacman -Sy mate mate-extra
elif [[ "$de" == "6" ]]; then
pacman -Sy deepin deepin-extra
fi
username - root
pacman -S grub
grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi --removable
grub-mkconfig -o /boot/grub/grub.cfg
echo "Root password"
passwd
' > setup_post.sh
fi
mv setup_post.sh /mnt/setup.sh
genfstab -U /mnt >> /mnt/etc/fstab
chmod +x /mnt/setup.sh
arch-chroot /mnt