-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·106 lines (86 loc) · 2.82 KB
/
setup.sh
File metadata and controls
executable file
·106 lines (86 loc) · 2.82 KB
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
dirname=$(dirname "$0")
source ${dirname}/helper.sh
# --------------------------------------------
# Redirect stdout and stderr
exec 3>&1 1>&2
# Set variables
EFI_partition=$1
boot_partition=$1
root_partition=$3
dual_boot=$4
# Determine CPU vendor
if [[ $(grep vendor_id /proc/cpuinfo | grep GenuineIntel) ]] ; then
log "CPU vendor: Intel"
ucode=intel-ucode
elif [[ $(grep vendor_id /proc/cpuinfo | grep AuthenticAMD) ]] ; then
ucode=amd-ucode
log "CPU vendor: AMD"
else
log "Could not determine CPU vendor, exitting"
exit 1
fi
# Install packages
log "Installing necessary packages"
pacman --noconfirm -S linux-zen linux-zen-headers linux-firmware nano base-devel networkmanager dialog lvm2 grub efibootmgr dosfstools os-prober mtools ntp git $ucode
# Enable networkmanager
log "Enabling NetworkManager"
systemctl enable NetworkManager
# Set locale
log "Generate and set locales"
sed -i -e 's/^#en_US\.UTF-8/en_US\.UTF-8/' /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
# Allow sudo
log "Setup sudo"
sed -i -e 's/^# %wheel ALL=(ALL:ALL) NOPASSWD/%wheel ALL=(ALL:ALL) NOPASSWD/' /etc/sudoers
# Setup mkinitcpio
log "Generate mkinitcpio"
sed -i -e 's/block filesystems/block encrypt lvm2 filesystems/g' /etc/mkinitcpio.conf
mkinitcpio -p linux-zen
# Setup GRUB
log "Installing GRUB"
cryptuuid=$(blkid /dev/$root_partition -s UUID -o value)
sed -i -e "s|loglevel=3 quiet|loglevel=3 cryptdevice=UUID=$cryptuuid:volgroup0:allow-discards quiet|g" /etc/default/grub
sed -i -e 's/#GRUB_DISABLE_OS_PROBER=false/GRUB_DISABLE_OS_PROBER=false/g' /etc/default/grub
grub-install --target=x86_64-efi --bootloader-id=GRUB
if [[ $dual_boot == "Different" ]] ; then
pacman --noconfirm -S ntfs-3g
log "Select Windows EFI partition"
partitions=$(lsblk -l -o NAME,TYPE,SIZE,PARTTYPENAME | awk "/part/")
options "$partitions"
WIN_partition=$(chooser "$partitions" "Partition")
log "Windows EFI: $G$WIN_partition$X"
mkdir windows
mount /dev/$WIN_partition windows
os-prober
grub-mkconfig -o /boot/grub/grub.cfg
umount windows
rmdir windows
else
os-prober
grub-mkconfig -o /boot/grub/grub.cfg
fi
# Set timezone and time
log "Setting time"
ln -sf /usr/share/zoneinfo/$zoneinfo /etc/localtime
ntpd -qg
hwclock --systohc
# Set keyboard layout
log "Change keyboard layout"
echo "KEYMAP=${kb_layout}" > /etc/vconsole.conf
log "User management"
username=$(input "Enter username" shown)
password=$(input "Enter root/${username} password" hidden)
echo "" 1>&3
# Set password for root
echo -e "$password\n$password" | passwd
# Make user
useradd -m -g users -G wheel $username
# Set pass for user
echo -e "$password\n$password" | passwd $username
# Copy files to user home
new_dir="/home/${username}/installer"
mkdir $new_dir
cp -r ${dirname}/. $new_dir
chown -R ${username}:users $new_dir