-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·170 lines (145 loc) · 5.59 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
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
#!/usr/bin/sh
init() {
# Vars
USERNAME='me'
HOSTNAME='hadal'
# Colors
NORMAL=$(tput sgr0)
YELLOW=$(tput setaf 7)
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
BRIGHT=$(tput bold)
UNDERLINE=$(tput smul)
}
confirm() {
echo -en "[${GREEN}y${NORMAL}/${RED}n${NORMAL}]: "
read -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
}
print_header() {
clear
echo -E "$BRIGHT
____ ___ .__ ______ __ .__
| | \____ |__| _____ / __ \/ |________|__|__ ___
| | / \| |/ \ > < __\_ __ \ \ \/ /
| | / | \ | Y Y \/ -- \ | | | \/ |> <
|______/|___|__/__|__|_|__/\________/__| |__| |__/__/\__\
$WHITE https://github.com/Unim8trix $NORMAL
"
}
install() {
echo -e "\n${YELLOW}Phase 1: setting up disk structure and install base system${NORMAL}\n"
echo -en "\n${RED}The NVMEN1 Disk will now be WIPED and all data will be destroyed! Are your sure to continue?${NORMAL}\n"
confirm
echo -e "${YELLOW}Erase existing luks partition NVME0n1p3${NORMAL}\n"
cryptsetup erase /dev/nvme0n1p3
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Wipe and delete old partition layout${NORMAL}\n"
wipefs -af /dev/nvme0n1
sgdisk --zap-all --clear /dev/nvme0n1
partprobe /dev/nvme0n1
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.2
echo -e "${YELLOW}Create new disk layout${NORMAL}\n"
sgdisk -n 0:0:+1024MiB -t 0:ef00 -c 0:esp /dev/nvme0n1
sgdisk -n 0:0:+4096MiB -t 0:8200 -c 0:swap /dev/nvme0n1
sgdisk -n 0:0:0 -t 0:8309 -c 0:luks /dev/nvme0n1
partprobe /dev/nvme0n1
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.2
echo -e "${YELLOW}Format EFI partition${NORMAL}\n"
mkfs.vfat -F 32 -n ESP /dev/nvme0n1p1
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.2
echo -e "${YELLOW}Create crypted partition for root${NORMAL}\n"
cryptsetup luksFormat /dev/nvme0n1p3
echo -e "${YELLOW}Open luks partion, type in your new password${NORMAL}\n"
cryptsetup open /dev/nvme0n1p3 cryptsys
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Create BTRFS filesystem and subvolumes${NORMAL}\n"
mkfs.btrfs -L ARCH -f /dev/mapper/cryptsys
mount /dev/mapper/cryptsys /mnt
btrfs sub create /mnt/@
btrfs sub create /mnt/@home
btrfs sub create /mnt/@snapshots
btrfs sub create /mnt/@cache
btrfs sub create /mnt/@kvm
btrfs sub create /mnt/@log
btrfs sub create /mnt/@tmp
sleep 1
umount /mnt
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Remount root volume with subvolume options${NORMAL}\n"
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@ /dev/mapper/cryptsys /mnt
mkdir -p /mnt/{boot,home,.snapshots,var/cache,var/lib/libvirt,var/log,var/tmp}
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@home /dev/mapper/cryptsys /mnt/home
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@snapshots /dev/mapper/cryptsys /mnt/.snapshots
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@cache /dev/mapper/cryptsys /mnt/var/cache
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@kvm /dev/mapper/cryptsys /mnt/var/lib/libvirt
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@log /dev/mapper/cryptsys /mnt/var/log
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@tmp /dev/mapper/cryptsys /mnt/var/tmp
mount /dev/nvme0n1p1 /mnt/boot
echo -e "${GREEN}Done${NORMAL}\n"
sleep 5
clear
echo -e "${YELLOW}Install minimal base system with pacstrap${NORMAL}\n"
sleep 2
pacstrap /mnt base base-devel linux linux-firmware btrfs-progs amd-ucode networkmanager zsh git-lfs curl wget man-db mlocate reflector neovim
echo -e "${GREEN}Done${NORMAL}\n"
sleep 2
echo -e "${YELLOW}Generate filesystem table${NORMAL}\n"
genfstab -p -L /mnt >> /mnt/etc/fstab
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Copy zsh profiles to /mnt/root${NORMAL}\n"
cp /etc/zsh/zprofile /mnt/root/.zprofile
cp /etc/zsh/zshrc /mnt/root/.zshrc
cp /root/HyprElite/chroot.sh /mnt/root && chmod +x /mnt/root/chroot.sh
echo -e "${YELLOW}Set you new root password${NORMAL}\n"
arch-chroot /mnt /bin/passwd root
sleep 0.5
arch-chroot /mnt /bin/chsh -s /bin/zsh
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Chroot into new system and create initial settings${NORMAL}\n"
sleep 3
arch-chroot /mnt /bin/zsh -c "/root/chroot.sh"
echo -e "${GREEN}Done${NORMAL}\n"
echo -e "${GREEN}Back in normal environment${NORMAL}\n"
sleep 3
echo -e "${YELLOW}Copy dotfiles${NORMAL}\n"
cp -R /root/HyprElite/config/* /mnt/home/me/.config/
chown -R me:users /mnt/home/me/.config/*
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Copy wallpapers${NORMAL}\n"
mkdir -p /mnt/home/me/Bilder/Wallpapers
cp -R /root/HyprElite/wallpapers/* /mnt/home/me/Bilder/Wallpapers/
chown -R me:users /mnt/home/me/Bilder/*
echo -e "${GREEN}Done${NORMAL}\n"
sleep 0.5
echo -e "${YELLOW}Unmounting filesystems${NORMAL}\n"
rm /mnt/root/chroot.sh
rm -rf /mnt/home/me/yay
umount -R /mnt
echo -e "${GREEN}Finished${NORMAL}\n"
echo -e "${YELLOW}System can now be rebooted${NORMAL}\n"
}
main() {
init
print_header
install
}
main && exit 0