-
Notifications
You must be signed in to change notification settings - Fork 23
/
install.sh
executable file
·52 lines (41 loc) · 1.39 KB
/
install.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
#!/usr/bin/bash
# print command before executing, and exit when any command fails
set -xe
# Update the system clock
timedatectl set-ntp true
read -r -p "Have you already partitioned your disk, built filesystem, and mounted to /mnt correctly? [y/N]" confirm
if [[ ! "$confirm" =~ ^(y|Y) ]]; then
exit
fi
# Necessary helper for sorting mirrors
curl -sSL 'https://www.archlinux.org/mirrorlist/?country=CN&protocol=https&ip_version=4' | sed 's/^#Server/Server/g' > /etc/pacman.d/mirrorlist
pacman -Sy
pacman -S --noconfirm pacman-contrib
update_mirrorlist(){
curl -sSL 'https://www.archlinux.org/mirrorlist/?country=CN&protocol=https&ip_version=4&use_mirror_status=on' | sed 's/^#Server/Server/g' | rankmirrors - > /etc/pacman.d/mirrorlist
}
# Generating fastest mirorrs
while true; do
update_mirrorlist
cat /etc/pacman.d/mirrorlist
read -r -p "Is this mirrorlist OK? [Y/n]" confirm
if [[ ! "$confirm" =~ ^(n|N) ]]; then
break
fi
done
pacman -Syy
# Install the base packages
pacstrap /mnt base base-devel linux linux-firmware
# Generate fstab
genfstab /mnt >> /mnt/etc/fstab
# Setup new system
rm -rf /mnt/archlinux-installer && mkdir /mnt/archlinux-installer
cp -r ./* /mnt/archlinux-installer/
arch-chroot /mnt /archlinux-installer/setup.sh
if [[ "$?" == "0" ]]; then
echo "Finished successfully."
read -r -p "Reboot now? [Y/n]" confirm
if [[ ! "$confirm" =~ ^(n|N) ]]; then
reboot
fi
fi