-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·107 lines (88 loc) · 2.38 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
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
#!/bin/bash
source install.config
set -e
function check_configuration {
log_progress "Checking configuration..."
if [ -z "$DESTINATION_DEVICE" ]; then
echo "DESTINATION_DEVICE is not defined."
return 1
else
echo "Found DESTINATION_DEVICE set to $DESTINATION_DEVICE"
fi
if [ -z "$COUNTRY" ]; then
echo "COUNTRY is not defined."
return 1
else
echo "Found COUNTRY set to $COUNTRY"
fi
if [ -z "$CITY" ]; then
echo "CITY is not defined."
return 1
else
echo "Found CITY set to $CITY"
fi
if [ -f "parted.config" ]; then
echo "Found parted configuration file."
else
echo "Cannot find parted configuration file."
return 1
fi
echo "Configuration OK."
}
function create_partitions {
log_progress "Creating partitions..."
parted -s ${DESTINATION_DEVICE} mklabel gpt
parted ${DESTINATION_DEVICE} < parted.config
}
function format_partitions {
log_progress "Formatting partitions..."
mkfs.vfat -F32 ${DESTINATION_DEVICE}1
mkfs.ext4 -F ${DESTINATION_DEVICE}2
mkswap ${DESTINATION_DEVICE}3
swapon ${DESTINATION_DEVICE}3
mkfs.ext4 -F ${DESTINATION_DEVICE}4
}
function mount_partitions_for_installation {
log_progress "Mounting partitions for installation..."
mount ${DESTINATION_DEVICE}2 /mnt
mkdir -p /mnt/boot
mount ${DESTINATION_DEVICE}1 /mnt/boot
mkdir -p /mnt/home
mount ${DESTINATION_DEVICE}4 /mnt/home
}
function find_the_fastest_mirror {
pacman -Sy --noconfirm reflector
eval $(echo "reflector --verbose --country '${COUNTRY}' -l 200 -p http --sort rate --save /etc/pacman.d/mirrorlist")
}
function install_the_base_system {
log_progress "Installing the base system..."
pacstrap /mnt base base-devel
}
function generate_fstab {
log_progress "Generating an fstab..."
genfstab -U -p /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab
}
function chroot_install {
log_progress "Continuing installation in chroot..."
cp chroot-install.sh /mnt
cp install.config /mnt
arch-chroot /mnt /bin/bash chroot-install.sh
rm -f /mnt/chroot-install.sh /mnt/install.config
}
function run {
check_configuration
create_partitions
format_partitions
mount_partitions_for_installation
find_the_fastest_mirror
install_the_base_system
generate_fstab
chroot_install
}
run
if [ $? = 0 ]; then
log_progress "Installation successful!"
else
log_progress "ERROR: Installation did not complete successfully!"
fi