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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
#!/bin/bash
# This is my installation script for Artix/Arch Linux.
# Check if the required config files are present
if [ ! -f "install_config/info.conf" ] || [ ! -f "install_config/packs.list" ] || [ ! -f "install_config/aur_packs.list" ] || [ ! -f "install_config/services.list" ] ; then
echo "You need to create the following files to commence installation: "
echo "install_config/info.conf: For system information."
echo "install_config/packs.list: For native packages."
echo "install_config/aur_pack.list: For AUR packages."
echo "install_config/services.list: For startup services."
echo "Until this issue is resolved, I cannot allow you to install."
exit 1
fi
# make sure the script is run as root
if [ "$EUID" -ne 0 ]; then
echo "You must be the root user to run this script." && exit 1
fi
echo "Greetings my fellow edgelord!"
echo "You are about to install the world's best linux distribution: Artix/Arch Linux."
# Gather information from configuration files
echo "Gathering information..."
echo "Reading system configuration information..."
username=$(grep username install_config/info.conf | awk ' { print $3 } ')
password=$(grep password install_config/info.conf | awk ' { print $3 } ')
passlength=$(echo "$password" | wc -m)
hostname=$(grep hostname install_config/info.conf | awk ' { print $3 } ')
disk=$(grep disk install_config/info.conf | awk ' { print $3 } ')
# Git repository to clone from
gitserver="172.16.0.100"
# read package list
echo "Reading native package and AUR package list..."
pack_list=$(grep -vi "#" install_config/packs.list | tr '\n' ' ')
aur_pack_list=$(grep -vi "#" install_config/aur_packs.list | tr '\n' ' ')
aur_pack_list=$(grep -vi "#" install_config/aur_packs.list | tr '\n' ' ')
service_list=$(grep -vi "#" install_config/services.list | tr '\n' ' ')
timezone=$(curl ifconfig.co/json | grep time_zone | awk ' { print $2 } ' | tr -d '"",')
countryiso=$(curl ifconfig.co/country-iso)
# test package lists for testing only
if [ $test -eq 1 ]; then
aur_pack_list=$(cat test_aur_packs.list | tr '\n' ' ')
pack_list=$(cat test_packs.list | tr '\n' ' ')
service_list=$(cat test_services.list | tr '\n' ' ')
fi
# determine if system is running BIOS or EFI
echo "Determining boot mode..."
if [[ -d "/sys/firmware/efi" ]]; then
bootmode="efi"
elif [[ ! -d "/sys/firmware/efi" ]]; then
bootmode="bios"
fi
# determine init system
echo "Determining init system..."
case "$(readlink /sbin/init)" in
"../lib/systemd/systemd")
initsys="systemd"
;;
"openrc-init")
initsys="openrc"
;;
"runit-init")
initsys="runit"
;;
"s6-init")
initsys="s6"
;;
"dinit-init")
initsys="dinit"
;;
* )
echo "Sorry, but $initsys is not supported"
exit 1
esac
# determine distro
echo "Determining distro..."
distro=$(lsb_release -is | tr [:upper:] [:lower:])
# get the memory amount to determine how big the swap partition should be
memory=$(awk '/MemTotal/ { print $2 } ' /proc/meminfo)
memory=$(($memory * 1024))
#memory=$(numfmt --to=iec $memory | tr '.' ',' | sed 's/,.//g')
memory=$(numfmt --to=iec $memory)
if grep -E "." <<< "${memory}"; then
ramnum=$(echo $memory | tr -dc '0-9 .')
ramletter=$(echo $memory | tr -dc 'A-Z')
ramnum=$(printf '%.*f\n' 0 $ramnum)
memory=$ramnum$ramletter
fi
echo "You have $memory of memory."
# verify settings
echo "Are these are the properties you want your system to have."
echo " "
echo "Username: ${username}"
echo "Password: ${passlength} characters long."
echo "Hostname: ${hostname} "
echo "Installation disk: ${disk} "
echo "Timezone: ${timezone} "
echo "Boot mode: ${bootmode} "
echo "Distro: ${distro} "
echo "Init system: ${initsys} "
echo " "
echo "!!! The partition table for ${disk} will be overwritten. !!!"
echo "!!! ALL DATA ON ${disk} WILL BE LOST FOREVER (A LONG TIME!) !!!"
# prompt user for confirmation
read -r -p "Is this information correct? " choice
case "$choice" in
y|Y|yes|Yes ) echo "Yes. Installation confirmed!";;
n|N|no|No ) echo "No. Now aborting installation..." && exit 0;;
* ) echo "$choice is an invalid response" && exit 1;;
esac
sleep 1
# prepare live system for setup
echo "Preparing for setup..."
# Enable Parallel Downloads, Package Verbosity, Highlighting, and Disk Space Checking
sed -i 's/^#ParallelDownloads = 5/ParallelDownloads = 10/' /etc/pacman.conf
sed -i 's/^#Color/Color/' /etc/pacman.conf
sed -i 's/^#CheckSpace/CheckSpace/' /etc/pacman.conf
case "$distro" in
"artix")
if [ ! -z $(grep "universe" "/etc/pacman.conf") ]; then
# add the universe repository
echo -e "\n[universe]\nInclude = /etc/pacman.d/mirrorlist-universe" >> /etc/pacman.conf
echo "
Server = https://universe.artixlinux.org/\$arch
Server = https://mirror1.artixlinux.org/universe/\$arch
Server = https://mirror.pascalpuffke.de/artix-universe/\$arch
Server = https://artixlinux.qontinuum.space/artixlinux/universe/os/\$arch
Server = https://mirror1.cl.netactuate.com/artix/universe/\$arch
Server = https://ftp.crifo.org/artix-universe/
" >> /etc/pacman.d/mirrorlist-universe
fi
;;
esac
pacman -Sy --noconfirm pacman-contrib gptfdisk rsync git espeak-ng lsb-release
# wipe disk
echo "Wiping..."
umount -l -v "${disk}"
sgdisk -Z "${disk}"
sgdisk -a 2048 -i "${disk}"
echo "And it's gone. I really hope nothing important was there..."
# partition disk
echo "Partitioning..."
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' "${disk}" # part 1 (BIOS Boot) will take up 1 MB not be mounted or formated
sgdisk -n 2::+1G --typecode=2:ef00 --change-name=2:'EFIBOOT' "${disk}" # part 2 (UEFI Boot) will take up 1 GB and will be formatted as FAT32
sgdisk -n 3::+"${memory}" --typecode=3:8200 --change-name=3:'SWAP' "${disk}" # part 3 (SWAP) will take up same as memory
sgdisk -n 4::+50G --typecode=4:8300 --change-name=4:'ROOT' "${disk}" # part 4 (ROOT) will take up 50 G be mounted on / and will be formated as ext4
sgdisk -n 5::-0 --typecode=5:8300 --change-name=5:'HOME' "${disk}" # part 5 (HOME) will take up remaining space and be mounted on /home and will be formated as ext4
# format partitions
echo "Formating..."
mkfs.fat -n "EFIBOOT" -F 32 "${disk}2"
mkswap -L "SWAP" "${disk}3"
mkfs.ext4 -L "ROOT" "${disk}4"
mkfs.ext4 -L "HOME" "${disk}5"
# mount partitions
echo "Mounting..."
swapon "${disk}3"
mkdir -v /mnt
mount -v -t ext4 "${disk}4" /mnt
mkdir -v /mnt/boot
mount -t vfat -L EFIBOOT /mnt/boot/
mkdir -pv /mnt/boot/efi
mkdir -v /mnt/home
mount -v -t ext4 "${disk}5" /mnt/home
mkdir -v /mnt/media
lsblk
# refresh mirrors now if using arch
case $distro in
"arch" )
echo "Refreshing mirrors..."
reflector --verbose -c $countryiso -a 48 -f 10 -l 10 --sort rate -p https --save /etc/pacman.d/mirrorlist
;;
esac
# commence installation
echo "Bootstraping time!"
case $distro in
"arch")
while true; do
ping -c 1 archlinux.org
pacstrap /mnt base base-devel linux linux-headers linux-lts linux-lts-headers grub efibootmgr vim git dash opendoas sudo openresolv zsh reflector archlinux-keyring archiso && break || sleep 5
done
# generate /etc/fstab
genfstab -U /mnt > /mnt/etc/fstab
;;
"artix")
while true; do
ping -c 1 artixlinux.org
basestrap /mnt base base-devel linux linux-headers linux-lts linux-lts-headers grub efibootmgr ${initsys} elogind-${initsys} pacman-contrib vim git opendoas dash sudo openresolv zsh artix-keyring artix-archlinux-support artools iso-profiles && break || sleep 5
done
# generate /etc/fstab
fstabgen -U /mnt > /mnt/etc/fstab
;;
"parabola")
while true; do
ping -c 1 parabola.nu
#initsys="openrc"
pacstrap /mnt base base-devel linux-libre linux-libre-headers linux-libre-lts linux-libre-lts-headers ${initsys} elogind-${initsys} grub efibootmgr libelogind udev-init-scripts pacman-contrib vim git opendoas dash sudo openresolv zsh archlinux-keyring parabola-keyring && break || sleep 5
done
esac
# mount psuedo filesystems because normal chroot requires it
mount -v -t proc /proc /mnt/proc
mount -v -t sysfs /sys /mnt/sys
mount -v --rbind /dev /mnt/dev
# copy live resolv.conf to new system
cp -v /etc/resolv.conf /mnt/etc/resolv.conf
# test to make sure the servers works
chroot /mnt ping -c 1 archlinux.org || exit 1
chroot /mnt ping -c 1 artixlinux.org || exit 1
# setup account
echo "Setting up user account..."
chroot /mnt useradd -m -G wheel,audio,video,optical,storage -s /bin/zsh ${username}
# setup passwords
chroot /mnt echo "root:${password}" | chpasswd
chroot /mnt /bin/sh -c "echo ${username}:${password} | chpasswd"
# setup grub and mkinit
echo "Setting up grub bootloader..."
case "$bootmode" in
"bios" )
echo "Setting up GRUB for BIOS..."
grub-install --boot-directory=/mnt/boot "${disk}"
;;
"efi" )
echo "Setting up GRUB for UEFI..."
grub-install --boot-directory=/mnt/boot --target=x86_64-efi --efi-directory=/mnt/boot --bootloader-id=GRUB "${disk}"
;;
esac
sed -i 's/^GRUB_TIMEOUT=5/GRUB_TIMEOUT=1/' /mnt/etc/default/grub
sed -i 's/^#GRUB_SAVEDEFAULT=true/GRUB_DEFAULT=true/' /mnt/etc/default/grub
sed -i 's/^#GRUB_DISABLE_SUBMENU=true/GRUB_DISABLE_SUBMENU=true/' /mnt/etc/default/grub
chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
echo "Setting up mkinitcpio..."
chroot /mnt mkinitcpio -P
#tweak config files
cp /etc/pacman.conf /mnt/etc/pacman.conf
cp /etc/pacman.d/mirrorlist-universe /mnt/etc/pacman.d/mirrorlist-universe
# Add support for Arch Linux Repositories if running artix linux and refresh mirrors
case "$distro" in
"arch" )
echo "Refreshing mirrorlist..."
chroot /mnt reflector --verbose -c $countryiso -a 48 -f 10 -l 10 --sort rate -p https --save /etc/pacman.d/mirrorlist
;;
"artix" )
echo "You are running Artix Linux. Now enabling required repositories..."
for repo in extra community; do
echo "Adding $repo..."
grep "^\[$repo\]" /mnt/etc/pacman.conf || echo -e "\n[$repo]\nInclude = /etc/pacman.d/mirrorlist-arch" >> /mnt/etc/pacman.conf
done
echo "Refreshing Artix mirrorlist..."
# grab the mirror urls and sort them using rankmirrors
curl -s "https://gitea.artixlinux.org/packagesA/artix-mirrorlist/raw/branch/master/trunk/mirrorlist" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 10 - > /mnt/etc/pacman.d/mirrorlist
echo "Refreshing Arch mirrorlist..."
curl -s "https://archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 10 - > /mnt/etc/pacman.d/mirrorlist-arch
;;
esac
echo "Refreshing mirrors..."
# refresh package repositories
while true; do
chroot /mnt pacman -Syy --noconfirm && break || sleep 5;
done
echo "Editing config files..."
# hostname
echo "$hostname" > /mnt/etc/hostname
# hosts
echo "127.0.0.1 localhost" >> /mnt/etc/hosts
echo "::1 localhost" >> /mnt/etc/hosts
# resolvconf.conf
echo "name_servers="1.1.1.1 1.0.0.1"" >> /mnt/etc/resolvconf.conf
# gpg conf
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
# locale.gen
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /mnt/etc/locale.gen
# sudoers.conf
sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /mnt/etc/sudoers
sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /mnt/etc/sudoers
# doas.conf
echo "permit persist :wheel" > /mnt/etc/doas.conf
# make.conf
echo "Calculating CPU cores..."
cpu_cores=$(grep -c ^processor /proc/cpuinfo)
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$cpu_cores\"/g" /mnt/etc/makepkg.conf
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $cpu_cores -z -)/g" /mnt/etc/makepkg.conf
# pacman.conf
sed -i 's/^#ParallelDownloads = 5/ParallelDownloads = 10/' /mnt/etc/pacman.conf
sed -i 's/^#Color/Color/' /mnt/etc/pacman.conf
sed -i 's/^#CheckSpace/CheckSpace/' /mnt/etc/pacman.conf
sed -i "/\[multilib\]/,/Include/"'s/^#//' /mnt/etc/pacman.conf
# setup timezone
echo "Setting up time..."
chroot /mnt ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime
chroot /mnt hwclock --systohc
# setup locale
echo "Setting up locale..."
chroot /mnt locale-gen
# replace bash symlink with dash symlink
chroot /mnt ln -sfT /bin/dash /bin/sh
echo "[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Target = bash
[Action]
Description = Re-pointing /bin/sh symlink to dash...
When = PostTransaction
Exec = /usr/bin/ln -sfT dash /usr/bin/sh
Depends = dash" > /usr/share/libalpm/hooks/bash_update.hook
# drivers
echo "Installing drivers..."
# install firmware
chroot /mnt pacman -Sy --noconfirm linux-firmware
# microcode
echo "Detecting CPU..."
proc_type=$(lscpu)
if grep -E "GenuineIntel" <<< ${proc_type}; then
echo "Installing Intel microcode"
chroot /mnt pacman -S --noconfirm intel-ucode
chroot /mnt proc_ucode=intel-ucode.img
elif grep -E "AuthenticAMD" <<< ${proc_type}; then
echo "Installing AMD microcode"
chroot /mnt pacman -S --noconfirm amd-ucode
chroot /mnt proc_ucode=amd-ucode.img
fi
# Detect and and install drivers for graphics
echo "Detecting graphics card..."
gpu_type=$(lspci)
if grep -E "NVIDIA|GeForce" <<< "${gpu_type}"; then
echo "Installing Nvidia drivers..."
chroot /mnt pacman -S nvidia --noconfirm --needed
chroot /mnt nvidia-xconfig
elif grep -E "Radeon|AMD" <<< "${gpu_type}"; then
echo "Installing AMD drivers..."
chroot /mnt pacman -S --noconfirm --needed xf86-video-amdgpu vulkan-radeon
elif grep -E "Integrated Graphics Controller" <<< ${gpu_type}; then
echo "Installing Intel drivers..."
chroot /mnt pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl vulkan-intel libva-intel-driver libva-utils
elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then
echo "Installing Intel UHD drivers..."
chroot /mnt pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl vulkan-intel libva-intel-driver libva-utils
fi
# install native packages
echo "Installing native packages..."
while true; do
chroot /mnt pacman -Sy --noconfirm --needed ${pack_list} && break || sleep 5;
done
echo "Enabling services..."
case "$initsys" in
"systemd" )
echo "Setting up services for systemd..."
for service in $service_list; do
chroot /mnt systemctl enable "${service}"
chroot /mnt systemctl enable "${service}d"
done
;;
"openrc")
echo "Setting up services for openrc..."
for service in $service_list; do
echo "Setting up service: $service"
chroot /mnt pacman -S --noconfirm "${service}-openrc"
chroot /mnt rc-update add "${service}"
done
;;
"runit")
echo "Setting up services for runit..."
for service in $service_list; do
echo "Setting up service: $service"
chroot /mnt pacman -S --noconfirm "${service}-runit"
chroot /mnt ln -sf /etc/runit/sv/"${service}" /etc/runit/runsvdir/current
done
;;
"s6" )
echo "Setting up services for s6"
for service in $service_list; do
echo "Setting up service: $service"
chroot /mnt pacman -S --noconfirm "${service}-s6"
chroot /mnt s6-rc-bundle-update -c /etc/s6/rc/compiled add default "${service}"
done
;;
"dinit" )
echo "Setting up services for dinit"
for service in $service_list; do
echo "Setting up service: $service"
chroot /mnt pacman -S --noconfirm "${service}-dinit"
chroot /mnt ln -s ../"${service}" /etc/dinit.d/boot.d
done
;;
esac
# install yay
echo "Installing yay..."
ping -c 1 https://aur.archlinux.org
chroot /mnt git clone https://aur.archlinux.org/yay.git /opt/yay
chroot /mnt chown -R ${username}:${username} /opt/yay
chroot --userspec=$username:$username /mnt /bin/sh -c "export HOME=/home/${username} && cd /opt/yay && makepkg -si --noconfirm"
# get ready to install aur packages
chroot /mnt /bin/sh -c mkdir /home/$username/.gnupg
chroot /mnt chown -R $username:$username /home/$username
# install aur packages
echo "Installing AUR packages..."
while true; do
chroot --userspec=$username:$username /mnt /bin/sh -c "export HOME=/home/${username} && yay -S --noconfirm ${aur_pack_list}" && break || sleep 5;
done
# clone repositories
ping -c 1 "$gitserver" || echo "Warning! The git server $gitserver might be down!"
git clone "git://$gitserver/dotfiles" /mnt/tmp/dotfiles
cp -rv /mnt/tmp/dotfiles/.* /mnt/home/user
rm -rfv /mnt/tmp/dotfiles/ /mnt/home/$username/.git
git clone "git://$gitserver/dwm" /mnt/home/$username/.local/src/dwm
git clone "git://$gitserver/dwmblocks" /mnt/home/$username/.local/src/dwmblocks
git clone "git://$gitserver/st" /mnt/home/$username/.local/src/st
git clone "git://$gitserver/dmenu" /mnt/home/$username/.local/src/dmenu
chroot /mnt /bin/sh -c "chown -R ${username}:${username} /home/${username}/.*"
chroot --userspec=$username:$username /mnt sudo make clean install -C /home/$username/.local/src/dwm
chroot --userspec=$username:$username /mnt sudo make clean install -C /home/$username/.local/src/dwmblocks
chroot --userspec=$username:$username /mnt sudo make clean install -C /home/$username/.local/src/st
chroot --userspec=$username:$username /mnt sudo make clean install -C /home/$username/.local/src/dmenu
chroot /mnt chown -R ${username}:${username} /home/${username}
chroot /mnt /bin/sh -c "chown -R ${username}:${username} /home/${username}"
# revert sudo rights to the way its meant to be
sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /mnt/etc/sudoers
sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /mnt/etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /mnt/etc/sudoers
sed -i 's/^#VerbosePkgLists/VerbosePkgLists/' /mnt/etc/pacman.conf
# success!! (hopefully)
echo "Installation complete!"
espeak-ng "Installation complete!"
echo "Artix Linux installation has completed btw."
chroot /mnt neofetch
# unmount filesystems
echo "Unmounting filesystems..."
umount -l -v -f /mnt
lsblk
echo "Be sure to disconnect the installation media before you reboot."
#read -r -p "Would you like to reboot now? " choice
#case $choice in
# y|Y|yes|Yes ) reboot now || exit 1;;
# n|N|no|No ) exit 0;;
# * ) echo "$choice is an invalid response" && exit 1;;
#esac
exit 0
|