fix: arrays not passed through with env

This commit is contained in:
AngeD 2023-11-09 15:02:35 +01:00
parent 956f923f3f
commit 2de46a3872
10 changed files with 151 additions and 148 deletions

View file

@ -6,17 +6,18 @@ cd "$(dirname "$0")"
(
case "$swapfile" in
[0-9]*)
size=$swapfile
size="$swapfile"
;;
true)
size="$(python -c "from math import ceil,log; print(2**ceil((log($swapfile)/log(2))))")"
ram="$(free -h | awk '$1 == "Mem:" {print $2}')"
size="$(python -c "from math import ceil,log; print(2**ceil((log($ram)/log(2))))")"
;;
*)
exit
;;
esac
dd if=/dev/zero of=/mnt/swapfile bs=1M count="$swapfile" status=progress
dd if=/dev/zero of=/mnt/swapfile bs=1M count="$size" status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
@ -25,75 +26,11 @@ cd "$(dirname "$0")"
cp -f rootfs/etc/pacman.conf /etc/pacman.conf
systemctl restart reflector
pacman -Sy
pacstrap -K /mnt/ "${pkg[@]}"
pacstrap -K --needed /mnt/ "${pkg[@]}"
cp -rfT rootfs/ /mnt/
genfstab -U /mnt >> /mnt/etc/fstab
genfstab -U /mnt/ >> /mnt/etc/fstab
awk 'p; /pattern/{p=1}' "$0" | arch-chroot /mnt/ bash -ex; exit
# System config
ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
hwclock --systohc
for l in "${locales[@]}"; do
sed -i "/^#\s*$l.UTF-8/s/^#\s*//" /etc/locale.gen
done
locale-gen
echo "LANG=$lang.UTF-8" > /etc/locale.conf
echo "$hostname" > /etc/hostname
# Drivers
case "$(lscpu | grep Vendor)" in
*AuthenticAMD*) cpu=amd ;;
*GenuineIntel*) cpu=intel ;;
esac
sed -i '/^HOOKS=(/s/filesystems/encrypt filesystems/' /etc/mkinitcpio.conf
# Services
pac "$cpu-ucode"
systemctl enable \
NetworkManager \
ip6tables \
iptables \
podman.socket \
reflector.timer \
systemd-resolved \
systemd-timesyncd
if ls -d /sys/class/power_supply/BAT*/ > /dev/null 2>&1; then
pac "${laptop_pkg[@]}"
systemctl enable tlp
fi
# Users
echo "root:$root_passwd" | chpasswd
useradd -mG wheel,video "$username" -s "${default_shell-/bin/bash}"
echo "$username:$user_passwd" | chpasswd
su "$username" -c 'xdg-user-dirs-update' 2> /dev/null || true
sed -i '/^#\s*%wheel\s\+ALL=(ALL:ALL)\s\+ALL/s/^#\s*//' /etc/sudoers
# Bootloader
bootctl install
root="$(findmnt -nr -o source /)"
cryptdev="$(cryptsetup status "$root" | grep device | awk '{print $2}' || true)"
if [ -n "$cryptdev" ]; then
uuid="$(blkid | grep "$cryptdev" | awk '{print $2}')"
options="cryptdevice=$uuid:$(basename "$root") "
fi
options="${options}root=$root"
for f in /boot/loader/entries/*.conf; do
cat << EOF >> "$f"
initrd /$cpu-ucode.img
options $options rw
EOF
done
echo -e "${BOLD}${GREEN}DONE. You can install a desktop environment \
(see README.md). Then, you can Ctrl+D, umount -R /mnt/ and reboot${NORMAL}"
arch-chroot /mnt/ bash -ex \
< config \
< src/lib.sh \
< src/install.sh