blob: abf407aac5e554a919c76b00ffff14a38e5911ae (
plain)
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
|
#!/bin/bash
# archinstall - A minimal Installation Script for Arch Linux
# Copyright (C) 2019 xengineering
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# stop at any error to optimize debugging:
set -e
# set timezone
print_ok "Setting timezone ..."
ln -sf $path_to_timezone /etc/localtime
hwclock --systohc
print_ok "Timezone set"
# localization
print_ok "Generating locales ..."
echo "$locales_to_generate" >> /etc/locale.gen
locale-gen
touch /etc/locale.conf
echo "LANG=$language" >> /etc/locale.conf
touch /etc/vconsole.conf
echo "KEYMAP=$keymap" >> /etc/vconsole.conf
print_ok "Locales generated"
# network configuration
print_ok "Setting /etc/hostname and /etc/hosts file ..."
touch /etc/hostname
echo "$hostname" > /etc/hostname
touch /etc/hosts
echo "127.0.0.1 localhost" >> /etc/hosts
echo "::1 localhost" >> /etc/hosts
print_ok "/etc/hostname and /etc/hosts configured"
# initramfs
if [ "$luks_encryption" == "yes" ];then
print_ok "Re-generating initramfs ..."
old_hooks_config_line=$(cat /etc/mkinitcpio.conf | grep "^HOOKS=")
print_ok "Old 'HOOKS' line in /etc/mkinitcpio : $old_hooks_config_line"
new_hooks_config_line="HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)"
print_ok "New 'HOOKS' line in /etc/mkinitcpio : $new_hooks_config_line"
sed -i "s|$old_hooks_config_line|$new_hooks_config_line|" /etc/mkinitcpio.conf
mkinitcpio -P
print_ok "Initramfs re-generated"
fi
# setting root password
print_ok "Setting default password for user 'root' ..."
echo "root:${DEFAULT_PASSWORD}" | chpasswd
print_ok "Default password for user 'root' set"
# install and configure bootloader
print_ok "Installing grub bootloader ..."
if [ "$boot_mode" == "uefi" ]; then
grub-install --target=x86_64-efi --efi-directory=/mnt --bootloader-id=GRUB \
--removable
else
grub-install --target=i386-pc $path_to_disk
fi
print_ok "Grub bootloader installed"
if [ $luks_encryption == "yes" ];then
print_ok "Setup of /etc/default/grub for LUKS encryption ..."
if [ "$boot_mode" == "uefi" ]; then
crypto_partition=${path_to_disk}3
else
crypto_partition=${path_to_disk}2
fi
cryptdevice_uuid=$(lsblk --fs | grep "$(basename $crypto_partition)" | awk '{print $3}')
print_ok "cryptdevice_uuid: $cryptdevice_uuid"
old_kernel_param_line=$(cat /etc/default/grub | grep "GRUB_CMDLINE_LINUX_DEFAULT")
print_ok "old_kernel_param_line: $old_kernel_param_line"
new_kernal_param_line="GRUB_CMDLINE_LINUX_DEFAULT=\"loglevel=3 quiet cryptdevice=UUID=${cryptdevice_uuid}:main root=/dev/mapper/main\""
print_ok "new_kernel_param_line: $new_kernal_param_line"
print_ok "Adding kernel parameters to /etc/default/grub ..."
sed -i "s|$old_kernel_param_line|$new_kernal_param_line|" /etc/default/grub
print_ok "Kernel parameters added to /etc/default/grub"
print_ok "Setup of /etc/default/grub for LUKS encryption done"
fi
print_ok "Generating /boot/grub/grub.cfg from /etc/default/grub ..."
grub-mkconfig -o /boot/grub/grub.cfg
print_ok "/boot/grub/grub.cfg generated"
|